@glinr/theauth-sveltekit
v3.0.2
Published
SvelteKit adapter for TheAuth - exposes agent auth as HTTP REST endpoints
Readme
@glinr/theauth-sveltekit
SvelteKit adapter for TheAuth.
Install
pnpm add theauth @glinr/@glinr/theauth-sveltekitUsage
Create src/routes/api/kavach/[...path]/+server.ts:
import { createKavach } from '@glinr/theauth';
import { kavachSvelteKit } from '@glinr/theauth-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 TheAuth REST API under /api/kavach: agent CRUD, authorization, delegations, audit logs, and dashboard stats.
With MCP OAuth 2.1
import { createMcpModule } from '@glinr/theauth/mcp';
import { kavachSvelteKit } from '@glinr/theauth-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-serverGET /.well-known/oauth-protected-resourcePOST /mcp/registerGET /mcp/authorizePOST /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 @glinr/theauth package.
Links
License
MIT
