open-index/open-npm huggingface dataset:
npm package: @kava-labs/react-scripts
Description: Configuration and scripts for Create React App.
Latest version: 5.0.1-kava.2

# react-scripts

This package includes scripts and configuration used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation:

- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) – How to create a new app.
- [User Guide](https://facebook.github.io/create-react-app/) – How to develop apps bootstrapped with Create React App.
npm package: @kavach/adapter-auth0
Description: Adapter to use auth0 with kavach.
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/adapter-auth0

Kavach adapter for [Auth0](https://auth0.com).

## Installation

```bash
bun add kavach @kavach/adapter-auth0
```

## Usage

```js
import { getAdapter } from '@kavach/adapter-auth0'
import { createAuth0Client } from '@auth0/auth0-spa-js'

const client = await createAuth0Client({
  domain: AUTH0_DOMAIN,
  clientId: AUTH0_CLIENT_ID,
  authorizationParams: {
    redirect_uri: window.location.origin
  }
})

const adapter = getAdapter(client)
```

## Auth modes

| Mode       | Mechanism                                                   |
| ---------- | ----------------------------------------------------------- |
| OAuth      | `loginWithRedirect` via social connection                   |
| Password   | `loginWithRedirect` with `Username-Password-Authentication` |
| Magic link | `loginWithRedirect` with `email` connection                 |

## Notes

- `onAuthChange` is a no-op — Auth0 SPA SDK doesn't expose a subscription API. Handle redirects via `parseUrlError` and `synchronize` after the callback.
- `synchronize` calls `getTokenSilently` + `getUser` to refresh the session.
npm package: @kavach/adapter-firebase
Description: Adapter to use firebase with kavach.
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/adapter-firebase

Kavach adapter for [Firebase Authentication](https://firebase.google.com/docs/auth).

## Installation

```bash
bun add kavach @kavach/adapter-firebase
```

## Usage

```js
import { getAdapter } from '@kavach/adapter-firebase'
import { initializeApp } from 'firebase/app'
import { getAuth } from 'firebase/auth'

const app = initializeApp({ apiKey: '...', authDomain: '...', projectId: '...' })
const auth = getAuth(app)

const adapter = getAdapter(auth)
```

## Auth modes

| Mode       | Mechanism                                |
| ---------- | ---------------------------------------- |
| OAuth      | `signInWithPopup` / `signInWithRedirect` |
| Password   | `signInWithEmailAndPassword`             |
| Magic link | `sendSignInLinkToEmail`                  |

## Data access

Pass your Firestore `db` instance (and optionally a `functions` instance for RPC calls):

```js
import { getActions } from '@kavach/adapter-firebase'
import { getFirestore } from 'firebase/firestore'
import { getFunctions } from 'firebase/functions'

const db = getFirestore(app)
const functions = getFunctions(app)

const actions = getActions(db, functions)

// Read
const { data } = await actions.get('users', {
  filter: { status: 'eq.active' },
  order: 'name.asc',
  limit: 20
})

// Insert (Firestore generates the ID)
await actions.put('users', { name: 'Alice', role: 'editor' })

// Upsert by ID
await actions.post('users', { id: 'user-1', name: 'Alice' })

// Update (requires id filter)
await actions.patch('users', { data: { role: 'admin' }, filter: { id: 'eq.user-1' } })

// Delete (requires id filter)
await actions.delete('users', { filter: { id: 'eq.user-1' } })

// Call a Callable Cloud Function
await actions.call('sendWelcomeEmail', { userId: 'user-1' })
```

### Supported filter operators

| Kavach operator | Firestore operator       |
| --------------- | ------------------------ |
| `eq`            | `==`                     |
| `neq`           | `!=`                     |
| `gt`            | `>`                      |
| `gte`           | `>=`                     |
| `lt`            | `<`                      |
| `lte`           | `<=`                     |
| `in`            | `in`                     |
| `is`            | `==` (null, true, false) |

> `like`, `ilike`, and array operators are not supported by Firestore.

### `patch` and `delete` require an `id` filter

Firestore operates on document references, not row-level queries. Both `patch` and `delete` require `filter: { id: 'eq.<docId>' }` to locate the document.

## RPC (Callable Cloud Functions)

Pass a `functions` instance as the second argument to `getActions()`:

```js
const actions = getActions(db, functions)
await actions.call('myCloudFunction', { input: 'value' })
```
npm package: @kavach/adapter-supabase
Description: Adapter to use supabase with kavach.
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/adapter-supabase

Kavach adapter for [Supabase](https://supabase.com).

## Installation

```bash
bun add kavach @kavach/adapter-supabase
```

## Usage

```js
import { getAdapter } from '@kavach/adapter-supabase'
import { createClient } from '@supabase/supabase-js'

const client = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
const adapter = getAdapter(client)
```

## Auth modes

| Mode       | Mechanism                                 |
| ---------- | ----------------------------------------- |
| OAuth      | `signInWithOAuth` (redirects to provider) |
| Magic link | `signInWithOtp` (email OTP)               |
| Password   | `signInWithPassword` (email + password)   |

## Logging table (optional)

If you enable logging in `kavach.config.js`, create this table in Supabase:

```sql
create table if not exists public.logs (
  id          uuid default uuid_generate_v4(),
  level       varchar,
  running_on  varchar,
  logged_at   timestamp with time zone,
  message     varchar,
  context     jsonb,
  data        jsonb,
  error       jsonb,
  written_at  timestamp with time zone default now()
);
```
npm package: @kavach/cli
Description: CLI for scaffolding Kavach into SvelteKit projects
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/cli

CLI tool for setting up Kavach authentication in SvelteKit projects.

## Installation

```bash
bun add -d @kavach/cli
```

## Commands

### `kavach init`

Interactively initialize Kavach in a SvelteKit project. The wizard:

1. Detects your package manager and TypeScript setup
2. Prompts you to select an auth adapter (Supabase, Firebase, Auth0, Amplify, or Convex)
3. Configures auth providers (Google, GitHub, magic link, password, etc.)
4. Sets up routes for auth, data, and logout
5. Patches `vite.config.js`, `hooks.server.js`, and `+layout.server.js`
6. Generates an auth page and any data/RPC routes
7. Installs required dependencies and updates `.env`

```bash
npx kavach init
# or
bunx kavach init
```

### `kavach add`

Add individual components to an existing Kavach setup:

```bash
kavach add auth-page   # Add an auth page
kavach add routes      # Add route configuration
```

## Requirements

Must be run from a SvelteKit project root (requires `svelte.config.js`).
npm package: @kavach/core
Description: Core utility functions for Kavach.
Author: Jerry Thomas
Latest version: 1.0.0-next.27

# kavach

Includes core components and type definitions used by the framework.

> Kavach - Protective Armour

## Logger

A minimalistic and extensible JSON logger. It offloads the actual log-writing task to writers.

The logger adds the following attributes to the logged data.

- logged_at: Timestamp of the log as ISO String
- running_on: Identifies where the logger was invoked from (server/browser)
- level: Logging level (error|warn|info|debug|trace)

## Logged Data

The logged data is expected to be provided as an object. The attributes of the object are merged with the base attributes before sending it to the writer.

Below are some examples assuming that the logger has been called on the server side at 8 am on 2022-11-05. The logger does not do any validation on the data structure it receives. It is up to the developer to ensure that the LogWriter will be able to handle the data appropriately.

### String message input

```js
logger.info('foo')
```

This will be sent to the writer as

```jsonc
{
  "level": "info",
  "running_on": "server",
  "logged_at": "2022-11-05T08:00:00.000Z",
  "message": "foo"
}
```

### Object as input

```js
logger.info({ message: 'foo' })
```

This will be sent to the writer as

```jsonc
{
  "level": "info",
  "running_on": "server",
  "logged_at": "2022-11-05T08:00:00.000Z",
  "message": "foo"
}
```

### Object as input (including nested detail)

```js
logger.info({ message: 'foo', data: { path: 'bar' } })
```

This will be sent to the writer as

```jsonc
{
  "level": "info",
  "running_on": "server",
  "logged_at": "2022-11-05T08:00:00.000Z",
  "message": "foo",
  "data": { "path": "bar" }
}
```

Following LogWriters are included in this repo

- [x] [Supabase](../../adapters/supabase/README.md)

```bash
pnpm add @kavach/core @kavach/adapter-supabase
```

```js
import { getLogWriter } from '@kavach/adapter-supabase'
import { getLogger } from '@kavach/core'

const writer = getLogWriter(config, options)
const logger = getLogger(writer, options)
```
npm package: @kavach/hashing
Description: Hashing functions.
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/hashing

Hashing utilities used internally by Kavach.

## Installation

```bash
bun add @kavach/hashing
```

## Usage

```js
import { md5 } from '@kavach/hashing'

const hash = md5('hello@example.com')
// => '5d41402abc4b2a76b9719d911017c592'
```

## API

### `md5(input: string): string`

Returns the MD5 hex digest of the input string. Used internally for generating Gravatar URLs.
npm package: @kavach/query
Description: Adapter-agnostic query filter parser for kavach
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/query

PostgREST-style query string parsing utilities for Kavach data routes.

## Installation

```bash
bun add @kavach/query
```

## Usage

```js
import { parseFilter, parseOrder, parseQueryParams } from '@kavach/query'

// Parse filter conditions
const filters = parseFilter({ name: 'eq.Alice', age: 'gte.18' })
// => [{ column: 'name', op: 'eq', value: 'Alice' }, { column: 'age', op: 'gte', value: '18' }]

// Parse order clauses
const order = parseOrder('name.asc,created_at.desc')
// => [{ column: 'name', direction: 'asc' }, { column: 'created_at', direction: 'desc' }]

// Parse all query params at once
const params = parseQueryParams({
  filter: { status: 'eq.active' },
  order: 'name.asc',
  limit: '10'
})
```

## API

| Export                     | Description                                                          |
| -------------------------- | -------------------------------------------------------------------- |
| `parseFilter(filter)`      | Parse a PostgREST-style filter object into `{ column, op, value }[]` |
| `parseOrder(order)`        | Parse an order string into `{ column, direction }[]`                 |
| `parseQueryParams(params)` | Parse all query params (filter, order, limit, offset)                |
| `sanitizeError(error)`     | Normalize error objects for safe client exposure                     |
| `isValidColumnName(name)`  | Validate a column name against an allowlist                          |
| `isValidOperator(op)`      | Check if a string is a supported filter operator                     |
| `OPERATORS`                | Set of standard filter operators (`eq`, `neq`, `lt`, `gt`, etc.)     |
| `ALL_OPERATORS`            | Set of all supported operators including array operators             |

## Supported Operators

Standard: `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `like`, `ilike`, `is`, `in`

Array: `cs`, `cd`, `ov`, `sl`, `sr`, `nxr`, `nxl`, `adj`
npm package: @kavach/sentry
Description: A sentry for role based route handling
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/sentry

Role-based route protection for SvelteKit apps.

## Installation

```bash
bun add @kavach/sentry
```

## Usage

```js
import { createSentry } from '@kavach/sentry'

const sentry = createSentry({
  app: {
    home: '/',
    login: '/auth',
    logout: '/logout',
    session: '/auth/session'
  },
  roles: {
    '*': { routes: ['/dashboard', '/profile'] },
    admin: { home: '/admin', routes: ['/admin', '/data/admin'] }
  }
})

// Update on sign in/out
sentry.setSession(session)

// Check a route
const result = sentry.protect('/dashboard')
// => { status: 200 }
// => { status: 401, redirect: '/auth' }
// => { status: 403, redirect: '/' }
```

## Configuration

### `SentryOptions`

| Option   | Type                        | Description                                                  |
| -------- | --------------------------- | ------------------------------------------------------------ |
| `app`    | `AppRoute`                  | App routes: `home`, `login`, `logout`, `session`             |
| `roles`  | `Record<string, RoleRoute>` | Role-based route rules. Use `'*'` for any authenticated user |
| `logger` | `Logger`                    | Optional `@kavach/logger` instance                           |

### Role configuration

```js
roles: {
  '*': {
    home: '/dashboard',    // optional: override home for authenticated users
    routes: ['/dashboard'] // routes accessible to any authenticated user
  },
  admin: {
    routes: ['/admin']     // routes restricted to the 'admin' role
  }
}
```

All routes are protected by default. Unauthenticated users are redirected to `app.login`. Authenticated users without the required role receive a 403.

## API

### `createSentry(options): Sentry`

Returns a sentry instance:

| Method                       | Description                                            |
| ---------------------------- | ------------------------------------------------------ |
| `sentry.setSession(session)` | Update the current session (call on auth state change) |
| `sentry.protect(path)`       | Returns `{ status: 200 }` or `{ status, redirect }`    |
| `sentry.app`                 | The resolved `AppRoute` config                         |

Used internally by the `kavach` package — you generally won't use this directly.
npm package: @kavach/svelte
Description: Drop in security for web apps.
Author: Jerry Thomas
Latest version: 1.0.0-next.27

# Kavach

> Kavach - Protective Armour

## Usage

```bash
pnpm add kavach @kavach/adapter-supabase
```

```js
import { createAdapter } from '@kavach/adapter-supabase'
import { createKavach } from '@kavach'

const adapter = getAdapter(config)
const kavach = createKavach(adapter)
```
npm package: @kavach/ui
Description: UI components for authentication and authorization
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/ui

Svelte UI components for Kavach authentication flows.

## Installation

```bash
bun add @kavach/ui
```

## Setup

Components read the Kavach instance from Svelte context. Set it in a parent layout:

```svelte
<script>
  import { setContext, onMount } from 'svelte'
  import { createKavach } from 'kavach'

  const kavach = $state({})
  setContext('kavach', kavach)

  onMount(async () => {
    const { adapter } = await import('$kavach/auth')
    Object.assign(kavach, createKavach(adapter))
  })
</script>
```

## Components

### `AuthProvider`

Sign-in button or form for a single provider. Supports OAuth, magic link (OTP), and password modes.

```svelte
<script>
  import { AuthProvider } from '@kavach/ui'
  let email = ''
  let password = ''
</script>

<!-- OAuth button -->
<AuthProvider mode="oauth" name="google" label="Continue with Google" />

<!-- Magic link form -->
<AuthProvider mode="otp" name="magic" label="Sign in with Magic Link" bind:value={email} />

<!-- Password form -->
<AuthProvider mode="password" name="email" label="Sign in" bind:value={email} bind:password />
```

**Props:** `mode` (`'oauth'|'otp'|'password'`), `name`, `label`, `scopes`, `value`, `password`, `onerror`, `onsuccess`

### `AuthPage`

Full auth page composed from a list of providers defined in `kavach.config.js`.

### `LoginCard` / `LoginCardList`

Card UI for a single provider or a rendered list of providers.

### `AuthGroup`

Groups multiple `AuthProvider` components.

### `AuthHandler`

Handles post-auth redirects and session state on the client.

### `AuthPassword`

Email + password input pair wired for sign-in.

### `AuthError`

Displays an authentication error message.

### `AuthResponse`

Displays an auth response (info, success, or error state).
npm package: @kavach/vite
Description: Vite plugin for Kavach authentication framework
Author: Jerry Thomas
Latest version: 1.0.0-next.37

# @kavach/vite

Vite plugin for the Kavach authentication framework.

## Installation

```bash
npm install @kavach/vite
# or
bun add @kavach/vite
```

## Usage

Add the plugin to your `vite.config.js`:

```js
import { sveltekit } from '@sveltejs/kit/vite'
import { kavach } from '@kavach/vite'

export default {
  plugins: [kavach(), sveltekit()]
}
```

## What it does

The Kavach Vite plugin provides virtual modules that are generated from your `kavach.config.js`:

- `$kavach/auth` - Authentication client instance
- `$kavach/config` - Parsed configuration
- `$kavach/routes` - Route protection rules
- `$kavach/providers` - Authentication providers

These modules are automatically generated at build time based on your configuration.

## Configuration

The plugin looks for `kavach.config.js` in your project root. You can specify a custom path:

```js
kavach({ configPath: './config/kavach.config.js' })
```

## API

### `kavach(options?)`

Creates a Vite plugin instance.

**Options:**
- `configPath` (string, optional) - Path to kavach config file. Defaults to `kavach.config.js` in project root.

### `parseConfig(config)`

Parses and validates a Kavach configuration object.

### `templates`

Template strings for generated files (auth pages, data routes, etc).

## License

MIT © [Jerry Thomas](https://jerrythomas.name)
npm package: @kavachos/astro
Description: Astro adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/astro

Astro adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/astro)](https://www.npmjs.com/package/@kavachos/astro)

## Install

```bash
pnpm add kavachos @kavachos/astro
```

## Usage

Create `src/pages/api/kavach/[...path].ts`:

```typescript
import { createKavach } from 'kavachos';
import { kavachAstro } from '@kavachos/astro';

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

const handlers = kavachAstro(kavach);

export const GET = handlers.GET;
export const POST = handlers.POST;
export const PATCH = handlers.PATCH;
export const DELETE = handlers.DELETE;
export const OPTIONS = handlers.OPTIONS;
```

Or use the catch-all handler to avoid listing each method:

```typescript
export const ALL = handlers.ALL;
```

This handles the full KavachOS REST API under `/api/kavach`: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachAstro } from '@kavachos/astro';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

const handlers = kavachAstro(kavach, { mcp });
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachAstro(kavach, options?)` returns an object with `GET`, `POST`, `PATCH`, `DELETE`, `OPTIONS`, and `ALL` handlers for Astro API routes.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |
| `basePath` | `string` | URL prefix before the catch-all segment. Defaults to `/api/kavach` |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/cli
Description: KavachOS CLI - setup wizard, dashboard launcher, and development tools
Author: KavachOS
Latest version: 0.1.1

# @kavachos/cli

Setup wizard and dev tools for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/cli)](https://www.npmjs.com/package/@kavachos/cli)

## Usage

No install required. Run with `npx`:

```bash
npx kavachos <command>
```

## Commands

### `init`

Prints setup instructions for adding KavachOS to a project, including install steps, configuration scaffold, and adapter options:

```bash
npx kavachos init
```

### `migrate`

Runs database migrations (auto-applies schema on first run):

```bash
npx kavachos migrate
```

### `dashboard`

Launches the standalone admin UI on port 3100 by default:

```bash
npx kavachos dashboard

# Custom port and API URL
npx kavachos dashboard --port 4000 --api http://localhost:3000
```

## Options

| Flag | Default | Description |
|---|---|---|
| `--port` | `3100` | Port for the dashboard server |
| `--api` | `http://localhost:3000` | KavachOS API URL |
| `--help, -h` | | Show help |
| `--version` | | Show version |

## Docs and support

- Documentation: [kavachos.com/docs](https://kavachos.com/docs)
- GitHub: [github.com/kavachos/kavachos](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/client
Description: TypeScript client for the KavachOS REST API
Author: KavachOS
Latest version: 0.1.0

# @kavachos/client

Zero-dependency TypeScript REST client for the KavachOS API.

[![npm](https://img.shields.io/npm/v/@kavachos/client?style=flat-square)](https://www.npmjs.com/package/@kavachos/client)

## Install

```bash
npm install @kavachos/client
```

## Usage

Works in Node.js, Cloudflare Workers, Deno, and the browser.

```ts
import { createKavachClient, KavachApiError } from '@kavachos/client';

const kavach = createKavachClient({
  apiUrl: 'https://auth.yourapp.com',
  tenantId: 'your-tenant-id',
  apiKey: process.env.KAVACH_API_KEY,
});

// Authorize a token
const result = await kavach.authorize({ token: incomingToken, requiredPermissions: ['read:data'] });

if (!result.ok) {
  throw new Error('Unauthorized');
}

// Manage agents
const agent = await kavach.createAgent({ name: 'my-bot', permissions: ['read:data'] });
const agents = await kavach.listAgents();

// Delegate permissions
await kavach.delegate({ agentId: agent.id, permissions: ['read:data'], expiresIn: '1h' });
```

## Error handling

```ts
try {
  await kavach.authorize({ token });
} catch (err) {
  if (err instanceof KavachApiError) {
    console.error(err.status, err.body.code);
  }
}
```

## Docs

[https://docs.kavachos.com/client](https://docs.kavachos.com/client)

## License

MIT
npm package: @kavachos/dashboard
Description: KavachOS admin dashboard - React UI for managing agents, permissions, and audit logs
Latest version: 0.1.3

# @kavachos/dashboard

Admin UI for managing agents, permissions, and audit logs.

[![npm](https://img.shields.io/npm/v/@kavachos/dashboard)](https://www.npmjs.com/package/@kavachos/dashboard)

## Install

```bash
npm install @kavachos/dashboard
```

Peer dependencies: React 19+

## Usage

### Embedded component

Mount the dashboard inside your existing React app:

```tsx
import { KavachDashboard } from "@kavachos/dashboard";

export function AdminPage() {
  return (
    <KavachDashboard
      apiUrl="http://localhost:3000"
    />
  );
}
```

The component connects to your KavachOS API and renders the full admin interface, including agent management, permission inspection, and audit log queries.

### Standalone server

Run the dashboard without a React app using the CLI:

```bash
npx kavachos dashboard
# Starts on http://localhost:3100

npx kavachos dashboard --port 4000 --api http://localhost:3000
```

This starts a Hono server that serves the dashboard UI and proxies API requests to your KavachOS backend.

## Options

| Prop / Flag | Default | Description |
|---|---|---|
| `apiUrl` / `--api` | `http://localhost:3000` | URL of your KavachOS API |
| `--port` | `3100` | Port for the standalone server |

## Built with

- React 19
- TailwindCSS 4
- TanStack Query 5
- Lucide React

## Docs and support

- Documentation: [kavachos.com/docs](https://kavachos.com/docs)
- GitHub: [github.com/kavachos/kavachos](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/electron
Description: KavachOS auth client for Electron desktop apps
Author: KavachOS
Latest version: 0.1.0

# @kavachos/electron

Electron integration for KavachOS — secure storage, OAuth windows, and IPC bridge.

[![npm](https://img.shields.io/npm/v/@kavachos/electron?style=flat-square)](https://www.npmjs.com/package/@kavachos/electron)

## Install

```bash
npm install @kavachos/electron
```

## Usage

Set up the IPC bridge in the main process, then use the provider in the renderer.

```ts
// main.ts (main process)
import { setupKavachIpc, createElectronStorage } from '@kavachos/electron';

const storage = createElectronStorage({ encryptionKey: process.env.STORAGE_KEY });
setupKavachIpc({ storage });
```

```tsx
// renderer.tsx
import { ElectronKavachProvider, useElectronKavachContext } from '@kavachos/electron';

function App() {
  return (
    <ElectronKavachProvider apiUrl="https://auth.yourapp.com" tenantId="your-tenant-id">
      <MainWindow />
    </ElectronKavachProvider>
  );
}
```

```ts
// OAuth login from renderer
import { openOAuthWindow } from '@kavachos/electron';

const result = await openOAuthWindow({ provider: 'google', redirectUri: 'kavach://oauth' });
```

## Exports

- `ElectronKavachProvider` / `ElectronKavachContext` / `useElectronKavachContext` — renderer-side provider
- `createElectronStorage` — encrypted keychain-backed storage
- `createMemoryStorage` — in-memory storage for testing
- `setupKavachIpc` / `createIpcStorage` / `KAVACH_IPC_CHANNELS` — main-process IPC setup
- `openOAuthWindow` — opens a managed OAuth popup window

## Docs

[https://docs.kavachos.com](https://docs.kavachos.com)

## License

MIT
npm package: @kavachos/expo
Description: React Native / Expo client for KavachOS auth
Author: KavachOS
Latest version: 0.1.0

# @kavachos/expo

Expo / React Native provider and hooks for KavachOS authentication.

[![npm](https://img.shields.io/npm/v/@kavachos/expo?style=flat-square)](https://www.npmjs.com/package/@kavachos/expo)

## Install

```bash
npm install @kavachos/expo
```

## Usage

Wrap your Expo app with `KavachExpoProvider`. Tokens are persisted using the configured storage (defaults to `expo-secure-store`).

```tsx
import { KavachExpoProvider, useSession, useUser, useSignIn } from '@kavachos/expo';

export default function App() {
  return (
    <KavachExpoProvider
      apiUrl="https://auth.yourapp.com"
      tenantId="your-tenant-id"
    >
      <RootNavigator />
    </KavachExpoProvider>
  );
}

function HomeScreen() {
  const { session } = useSession();
  const { user } = useUser();
  const { signIn } = useSignIn();

  return session
    ? <Text>Hello, {user?.email}</Text>
    : <Button title="Sign in" onPress={() => signIn({ email, password })} />;
}
```

## Exports

- `KavachExpoProvider` — context provider with secure storage support
- `useSession` — current session and loading state
- `useUser` — authenticated user object
- `useSignIn` / `useSignOut` / `useSignUp` — auth actions
- `useAgents` — manage AI agents for the current user
- `useKavachContext` — raw context access

## Docs

[https://docs.kavachos.com](https://docs.kavachos.com)

## License

MIT
npm package: @kavachos/express
Description: Express adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/express

Express adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/express)](https://www.npmjs.com/package/@kavachos/express)

## Install

```bash
pnpm add kavachos @kavachos/express
```

## Usage

```typescript
import express from 'express';
import { createKavach } from 'kavachos';
import { kavachExpress } from '@kavachos/express';

const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

// Mount all KavachOS routes at /auth
app.use('/auth', kavachExpress(kavach));

app.listen(3000);
```

This mounts the full KavachOS REST API: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachExpress } from '@kavachos/express';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

app.use('/auth', kavachExpress(kavach, { mcp }));
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachExpress(kavach, options?)` returns an Express `Router`. Pass it to `app.use()` with your chosen prefix.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/fastify
Description: Fastify adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/fastify

Fastify adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/fastify)](https://www.npmjs.com/package/@kavachos/fastify)

## Install

```bash
pnpm add kavachos @kavachos/fastify
```

## Usage

```typescript
import Fastify from 'fastify';
import { createKavach } from 'kavachos';
import { kavachFastify } from '@kavachos/fastify';

const app = Fastify();

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

// Register all KavachOS routes under /api/kavach
await app.register(kavachFastify(kavach), { prefix: '/api/kavach' });

await app.listen({ port: 3000 });
```

This registers the full KavachOS REST API: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachFastify } from '@kavachos/fastify';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

await app.register(kavachFastify(kavach, { mcp }), { prefix: '/api/kavach' });
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachFastify(kavach, options?)` returns an async Fastify plugin. Pass it to `app.register()` and use Fastify's built-in `prefix` option to choose your mount path.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/gateway
Description: Standalone auth proxy for KavachOS - enforces auth, authorization, and audit in front of any API or MCP server
Author: KavachOS
Latest version: 2.0.0

# @kavachos/gateway

Standalone auth proxy that enforces KavachOS policies in front of any HTTP service.

[![npm](https://img.shields.io/npm/v/@kavachos/gateway?style=flat-square)](https://www.npmjs.com/package/@kavachos/gateway)

## Install

```bash
npm install @kavachos/gateway
```

## Usage

Create a gateway with route policies, then call `handle` on every incoming request.

```ts
import { createGateway, loadConfigFile } from '@kavachos/gateway';

const gateway = createGateway({
  kavachApiUrl: 'https://auth.yourapp.com',
  tenantId: 'your-tenant-id',
  upstream: 'http://localhost:3001',
  policies: [
    {
      match: { path: '/api/**', methods: ['GET', 'POST'] },
      require: { permissions: ['api:access'] },
      rateLimit: { requests: 100, windowMs: 60_000 },
    },
  ],
});

// Node HTTP server
import { createServer } from 'http';
createServer((req, res) => gateway.handle(req, res)).listen(8080);
```

### File-based config

```ts
const config = await loadConfigFile('./kavach-gateway.json');
const gateway = createGateway(config);
```

## Exports

- `createGateway` — creates a gateway instance
- `loadConfigFile` — loads gateway config from a JSON/YAML file
- `matchPolicy` — utility to test a request against a policy

## Docs

[https://docs.kavachos.com/gateway](https://docs.kavachos.com/gateway)

## License

MIT
npm package: @kavachos/hono
Description: Hono adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/hono

Hono adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/hono)](https://www.npmjs.com/package/@kavachos/hono)

## Install

```bash
pnpm add kavachos @kavachos/hono
```

## Usage

```typescript
import { serve } from '@hono/node-server';
import { Hono } from 'hono';
import { createKavach } from 'kavachos';
import { kavachHono } from '@kavachos/hono';

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

const app = new Hono();

// Mount all KavachOS routes at /api/kavach
app.route('/api/kavach', kavachHono(kavach));

serve({ fetch: app.fetch, port: 3000 });
```

This mounts the full KavachOS REST API: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachHono } from '@kavachos/hono';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

app.route('/api/kavach', kavachHono(kavach, { mcp }));
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachHono(kavach, options?)` returns a `Hono` instance with all routes registered. Pass it to `app.route()` with your chosen prefix.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/nestjs
Description: NestJS adapter for KavachOS
Author: KavachOS
Latest version: 2.0.0

# @kavachos/nestjs

NestJS adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/nestjs?style=flat-square)](https://www.npmjs.com/package/@kavachos/nestjs)

## Install

```bash
npm install kavachos @kavachos/nestjs
```

## Usage

### Module import

```typescript
import { Module } from "@nestjs/common";
import { KavachModule } from "@kavachos/nestjs";

@Module({
  imports: [
    KavachModule.forRoot({
      database: { provider: "sqlite", url: "kavach.db" },
    }),
  ],
})
export class AppModule {}
```

### Middleware

```typescript
import { createKavach } from "kavachos";
import { kavachMiddleware } from "@kavachos/nestjs";

const kavach = createKavach({
  database: { provider: "postgres", url: process.env.DATABASE_URL },
});

// Apply as NestJS middleware
app.use("/api/kavach", kavachMiddleware(kavach));
```

## Docs

[docs.kavachos.com/docs/adapters/nestjs](https://docs.kavachos.com/docs/adapters/nestjs)

## License

MIT
npm package: @kavachos/nextjs
Description: Next.js App Router adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/nextjs

Next.js adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/nextjs)](https://www.npmjs.com/package/@kavachos/nextjs)

## Install

```bash
pnpm add kavachos @kavachos/nextjs
```

## Usage

Create `app/api/kavach/[...kavach]/route.ts`:

```typescript
import { createKavach } from 'kavachos';
import { kavachNextjs } from '@kavachos/nextjs';

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

const handlers = kavachNextjs(kavach);

export const GET = handlers.GET;
export const POST = handlers.POST;
export const PATCH = handlers.PATCH;
export const DELETE = handlers.DELETE;
export const OPTIONS = handlers.OPTIONS;
```

This handles the full KavachOS REST API under `/api/kavach`: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachNextjs } from '@kavachos/nextjs';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

const handlers = kavachNextjs(kavach, { mcp });
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachNextjs(kavach, options?)` returns an object with `GET`, `POST`, `PATCH`, `DELETE`, and `OPTIONS` handlers for the Next.js App Router.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |
| `basePath` | `string` | URL prefix before the catch-all segment. Defaults to `/api/kavach` |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/nuxt
Description: Nuxt adapter for KavachOS - exposes agent auth as HTTP REST endpoints via H3
Author: KavachOS
Latest version: 2.0.0

# @kavachos/nuxt

Nuxt adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/nuxt)](https://www.npmjs.com/package/@kavachos/nuxt)

## Install

```bash
pnpm add kavachos @kavachos/nuxt
```

## Usage

Create `server/api/kavach/[...].ts`:

```typescript
import { createKavach } from 'kavachos';
import { kavachNuxt } from '@kavachos/nuxt';

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

export default kavachNuxt(kavach);
```

This handles the full KavachOS REST API under `/api/kavach`: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachNuxt } from '@kavachos/nuxt';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

export default kavachNuxt(kavach, { mcp });
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachNuxt(kavach, options?)` returns an H3 `EventHandler` for use as a Nuxt server route.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |
| `basePath` | `string` | URL prefix before the catch-all segment. Defaults to `/api/kavach` |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/prisma
Description: Prisma database adapter for KavachOS - use PrismaClient as your KavachOS database backend
Author: KavachOS
Latest version: 2.0.0

# @kavachos/prisma

Prisma database adapter for KavachOS. Use PrismaClient as your KavachOS database backend.

[![npm](https://img.shields.io/npm/v/@kavachos/prisma?style=flat-square)](https://www.npmjs.com/package/@kavachos/prisma)

## Install

```bash
npm install kavachos @kavachos/prisma @prisma/client
```

## Usage

```typescript
import { createKavach } from "kavachos";
import { PrismaClient } from "@prisma/client";
import { kavachPrisma } from "@kavachos/prisma";

const prisma = new PrismaClient();

const kavach = createKavach({
  database: kavachPrisma(prisma),
});
```

## When to use

Use this adapter if your app already uses Prisma and you want KavachOS to share the same database connection and transaction context. For new projects, the built-in database providers (`sqlite`, `postgres`, `mysql`, `d1`) are simpler.

## Docs

[docs.kavachos.com/docs/adapters/prisma](https://docs.kavachos.com/docs/adapters/prisma)

## License

MIT
npm package: @kavachos/react
Description: React hooks for KavachOS auth
Author: KavachOS
Latest version: 0.2.0

# @kavachos/react

React provider and hooks for KavachOS authentication.

[![npm](https://img.shields.io/npm/v/@kavachos/react?style=flat-square)](https://www.npmjs.com/package/@kavachos/react)

## Install

```bash
npm install @kavachos/react
```

## Usage

Wrap your app with `KavachProvider`, then use hooks anywhere in the tree.

```tsx
import { KavachProvider, useSession, useUser, useSignIn, useSignOut } from '@kavachos/react';

function App() {
  return (
    <KavachProvider apiUrl="https://auth.yourapp.com" tenantId="your-tenant-id">
      <Dashboard />
    </KavachProvider>
  );
}

function Dashboard() {
  const { session, isLoading } = useSession();
  const { user } = useUser();
  const { signIn } = useSignIn();
  const { signOut } = useSignOut();

  if (isLoading) return <p>Loading...</p>;
  if (!session) return <button onClick={() => signIn({ email, password })}>Sign in</button>;

  return (
    <div>
      <p>Welcome, {user?.email}</p>
      <button onClick={signOut}>Sign out</button>
    </div>
  );
}
```

## Exports

- `KavachProvider` — context provider, wrap your app root
- `useSession` — current session and loading state
- `useUser` — authenticated user object
- `useSignIn` — sign-in action
- `useSignOut` — sign-out action
- `useSignUp` — sign-up action
- `useAgents` — manage AI agents for the current user
- `useKavachContext` — raw context access

## Docs

[https://docs.kavachos.com](https://docs.kavachos.com)

## License

MIT
npm package: @kavachos/solidstart
Description: SolidStart adapter for KavachOS
Author: KavachOS
Latest version: 2.0.0

# @kavachos/solidstart

SolidStart adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/solidstart?style=flat-square)](https://www.npmjs.com/package/@kavachos/solidstart)

## Install

```bash
npm install kavachos @kavachos/solidstart
```

## Usage

```typescript
import { createKavach } from "kavachos";
import { kavachSolidStart } from "@kavachos/solidstart";

const kavach = createKavach({
  database: { provider: "sqlite", url: "kavach.db" },
});

// Mount in your SolidStart API routes
export const { GET, POST } = kavachSolidStart(kavach);
```

## Docs

[docs.kavachos.com/docs/adapters/solidstart](https://docs.kavachos.com/docs/adapters/solidstart)

## License

MIT
npm package: @kavachos/svelte
Description: Svelte stores for KavachOS auth
Author: KavachOS
Latest version: 0.1.0

# @kavachos/svelte

Svelte stores for KavachOS authentication.

[![npm](https://img.shields.io/npm/v/@kavachos/svelte?style=flat-square)](https://www.npmjs.com/package/@kavachos/svelte)

## Install

```bash
npm install @kavachos/svelte
```

## Usage

Create a client and stores at the top of your app, then subscribe in any component.

```ts
// lib/kavach.ts
import { createKavachClient, createAgentStore } from '@kavachos/svelte';

export const kavach = createKavachClient({
  apiUrl: 'https://auth.yourapp.com',
  tenantId: 'your-tenant-id',
});

export const agents = createAgentStore({ client: kavach });
```

```svelte
<script>
  import { kavach, agents } from '$lib/kavach';

  const { session, user } = kavach;
</script>

{#if $session}
  <p>Welcome, {$user?.email}</p>
  <button on:click={() => kavach.signOut()}>Sign out</button>
{:else}
  <button on:click={() => kavach.signIn({ email, password })}>Sign in</button>
{/if}
```

## Exports

- `createKavachClient` — creates a reactive Svelte store client
- `createAgentStore` — creates a store for managing AI agents

## Docs

[https://docs.kavachos.com](https://docs.kavachos.com)

## License

MIT
npm package: @kavachos/sveltekit
Description: SvelteKit adapter for KavachOS - exposes agent auth as HTTP REST endpoints
Author: KavachOS
Latest version: 2.0.0

# @kavachos/sveltekit

SvelteKit adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/sveltekit)](https://www.npmjs.com/package/@kavachos/sveltekit)

## Install

```bash
pnpm add kavachos @kavachos/sveltekit
```

## Usage

Create `src/routes/api/kavach/[...path]/+server.ts`:

```typescript
import { createKavach } from 'kavachos';
import { kavachSvelteKit } from '@kavachos/sveltekit';

const kavach = createKavach({
  database: { provider: 'sqlite', url: 'kavach.db' },
});

const handlers = kavachSvelteKit(kavach);

export const GET = handlers.GET;
export const POST = handlers.POST;
export const PATCH = handlers.PATCH;
export const DELETE = handlers.DELETE;
export const OPTIONS = handlers.OPTIONS;
```

This handles the full KavachOS REST API under `/api/kavach`: agent CRUD, authorization, delegations, audit logs, and dashboard stats.

### With MCP OAuth 2.1

```typescript
import { createMcpModule } from 'kavachos/mcp';
import { kavachSvelteKit } from '@kavachos/sveltekit';

const mcp = createMcpModule({
  issuer: 'https://your-app.com',
  // ...
});

const handlers = kavachSvelteKit(kavach, { mcp });
```

When `mcp` is provided, the OAuth 2.1 endpoints are enabled:

- `GET /.well-known/oauth-authorization-server`
- `GET /.well-known/oauth-protected-resource`
- `POST /mcp/register`
- `GET /mcp/authorize`
- `POST /mcp/token`

## API surface

`kavachSvelteKit(kavach, options?)` returns an object with `GET`, `POST`, `PATCH`, `DELETE`, and `OPTIONS` handlers for SvelteKit's `+server.ts` files.

| Option | Type | Description |
|--------|------|-------------|
| `mcp` | `McpAuthModule` | Enables MCP OAuth 2.1 endpoints |
| `basePath` | `string` | URL prefix before the catch-all segment. Defaults to `/api/kavach` |

For full docs on agent identity, permissions, delegation, and audit, see the main [kavachos](https://www.npmjs.com/package/kavachos) package.

## Links

- [Documentation](https://kavachos.dev/docs)
- [GitHub](https://github.com/kavachos/kavachos)

## License

MIT
npm package: @kavachos/tanstack
Description: TanStack Start adapter for KavachOS
Author: KavachOS
Latest version: 2.0.0

# @kavachos/tanstack

TanStack Start adapter for KavachOS.

[![npm](https://img.shields.io/npm/v/@kavachos/tanstack?style=flat-square)](https://www.npmjs.com/package/@kavachos/tanstack)

## Install

```bash
npm install kavachos @kavachos/tanstack
```

## Usage

```typescript
import { createKavach } from "kavachos";
import { kavachTanStack } from "@kavachos/tanstack";

const kavach = createKavach({
  database: { provider: "sqlite", url: "kavach.db" },
});

// Mount in your TanStack Start API routes
export const { GET, POST } = kavachTanStack(kavach);
```

## Docs

[docs.kavachos.com/docs/adapters/tanstack](https://docs.kavachos.com/docs/adapters/tanstack)

## License

MIT