Introducing Auth and Testing in v0.0.1-experimental.15
May 8, 2026 · A70III
We're excited to introduce the biggest release yet — v0.0.1-experimental.15 — featuring a built-in authentication system and testing utilities.
v0.0.1-experimental.15 Features
This release includes:
Auth System
- JWT - Sign and verify access/refresh token pairs
- Session management - In-memory sessions with auto-expiry and refresh
- RBAC - Role-based access control with role inheritance
- OAuth2 - Built-in clients for Google, GitHub, Facebook, and Discord
Testing Utilities
- TestApp - Lightweight in-process app for testing routes and middleware
- TestClient - HTTP verb helpers for making test requests
- Expect helpers -
expect(),expectStatus(),expectBody()for assertions - Mocking - Spies, stubs, mock database, and mock request/context
Auth Module
The Auth class bundles JWT, sessions, RBAC, and OAuth2 into one interface:
typescript
import { createAuth } from "kyrin";
const auth = createAuth({
jwtSecret: process.env.JWT_SECRET!,
});
// Sign tokens
const tokens = await auth.signToken("user-123", { role: "admin" });
// Create a session
const session = auth.createSession("user-123", { role: "admin" });
// Define roles and check permissions
auth.roles.define("admin", ["*"]);
auth.roles.define("user", ["read:own", "update:own"]);
auth.roles.assign("user-123", ["admin"]);You can also use standalone functions:
typescript
import { createAccessToken, verifyToken } from "kyrin";
import { createSession, getSession } from "kyrin";
import { defineRole, hasPermission } from "kyrin";
import { setOAuthConfig, getAuthorizationUrl } from "kyrin";Testing Utilities
Kyrin now ships with built-in testing tools — no Jest or Vitepress needed.
typescript
import { createApp, expect, expectStatus, expectBody } from "kyrin";
const app = createApp();
app.get("/hello", () => ({ message: "Hello!" }));
const client = app.getClient();
const res = await client.get("/hello");
expectStatus(res.status).toBe(200);
expectBody(res.body).toEqual({ message: "Hello!" });Mocking utilities are also included:
spy()- Wrap functions and inspect callsstub()- Create fake objects that satisfy a typeMockDatabase- In-memory database for testing queriesMockResponse/mockRequest/createMockContext- Simulate HTTP primitives
References
- v0.0.1-experimental.15 Release
- Commit:
1cee22f- chore: bump version to v0.0.1-experimental.15 - Commit:
6c80dcc- update lib and dependencies - Commit:
d785c7b- fix: resolve TypeScript build errors in test files - npm: [email protected]
Stay tuned for more updates!