Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .changeset/tier1-adoption-batch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@glinr/theauth": minor
"@glinr/theauth-cli": minor
"@glinr/theauth-mcp": minor
"@glinr/theauth-conformance": minor
"@glinr/theauth-agent-frameworks": minor
"@glinr/create-theauth-app": minor
"@glinr/theauth-gateway": minor
---

Add `theauth dev` (zero-config local first run), a Cloudflare Workers template, an opt-in `adminApi` plugin with an admin MCP server (read-only by default, writes gated by approval), a black-box agent-auth conformance suite, and LangGraph and Mastra approval wrappers.

Breaking behavior in the gateway: the client `Authorization` and `DPoP` headers are no longer forwarded to the upstream by default. Opt out with `--forward-auth` or `stripAuthHeader: false`. The gateway also gains an MCP mode, a 10 MiB request body limit, a 30 second upstream header timeout, and hop-by-hop and `X-Forwarded-*` header handling. Core gains a browser-safe `@glinr/theauth/browser` entry.
3 changes: 1 addition & 2 deletions apps/marquee-demo/src/app/api/demo/delegate/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* POST /api/demo/delegate
* Step 4: Delegate from the parent agent to a sub-agent with narrower scope.
* POST /api/demo/delegate (step 4): delegates from the parent agent to a narrower sub-agent.
*/

import { NextResponse } from "next/server";
Expand Down
11 changes: 3 additions & 8 deletions apps/marquee-demo/src/app/api/demo/export/route.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
/**
* POST /api/demo/export
* Step 5: Export the audit trail as a signed JSON file.
*
* The vc/audit-export.ts module (exportAuditAsVC) does not yet exist in this
* branch; it is shipping in a parallel PR (v3/vc-audit-export).
* TODO(v3): replace signedExport() with importaed exportAuditAsVC once that PR merges.
* POST /api/demo/export (step 5): exports the audit trail as a signed JSON file.
* TODO(v3): replace signedExport() with exportAuditAsVC once the vc/audit-export PR merges.

Check warning on line 3 in apps/marquee-demo/src/app/api/demo/export/route.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=glincker_theauth&issues=AaFIS0wnW1pCEb9gxYsT&open=AaFIS0wnW1pCEb9gxYsT&pullRequest=256
*/

import { NextResponse } from "next/server";
Expand Down Expand Up @@ -55,8 +51,7 @@
proof: {
type: "TheAuthSimulatedProof",
created: now,
// TODO(v3): replace with real Ed25519Signature2020 from exportAuditAsVC
// once packages/core/src/vc/audit-export.ts lands in v3/vc-audit-export.
// TODO(v3): swap for a real Ed25519Signature2020 once exportAuditAsVC lands.

Check warning on line 54 in apps/marquee-demo/src/app/api/demo/export/route.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=glincker_theauth&issues=AaFIS0wnW1pCEb9gxYsU&open=AaFIS0wnW1pCEb9gxYsU&pullRequest=256
note: "Proof stub, full VC signing ships in v3/vc-audit-export PR",
},
};
Expand Down
3 changes: 1 addition & 2 deletions apps/marquee-demo/src/app/api/demo/reset/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* POST /api/demo/reset
* Clear the current browser's demo session so it can restart from step 1.
* POST /api/demo/reset: clears this browser's demo session so it can restart from step 1.
*/

import { NextResponse } from "next/server";
Expand Down
9 changes: 2 additions & 7 deletions apps/marquee-demo/src/app/api/demo/signup/route.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
/**
* POST /api/demo/signup
* Step 1: Register a user with a simulated passkey.
*
* In a production passkey flow, we would call navigator.credentials.create()
* in the browser and verify the attestation here. For the demo we simulate
* the passkey ceremony and create a real TheAuth session record so all
* downstream steps use authentic data.
* POST /api/demo/signup (step 1). Simulates the passkey ceremony and creates a real session record.
* Production would call navigator.credentials.create() and verify the attestation here.
*/

import { generateId } from "@glinr/theauth";
Expand Down
3 changes: 1 addition & 2 deletions apps/marquee-demo/src/app/api/demo/spawn-agent/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* POST /api/demo/spawn-agent
* Step 2: Spawn an agent with read-only access to the "calendar" mock tool.
* POST /api/demo/spawn-agent (step 2): spawns an agent with read-only access to the "calendar" mock tool.
*/

import { NextResponse } from "next/server";
Expand Down
4 changes: 1 addition & 3 deletions apps/marquee-demo/src/app/api/demo/state/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/**
* GET /api/demo/state
* Returns the current demo step state for the active session.
* The UI polls this to sync after actions.
* GET /api/demo/state: current demo step state for the session. The UI polls this to sync.
*/

import { NextResponse } from "next/server";
Expand Down
8 changes: 2 additions & 6 deletions apps/marquee-demo/src/app/api/demo/tool-call/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* POST /api/demo/tool-call
* Step 3: Execute a mock calendar tool call through the TheAuth authorization engine.
* The tool surface is simulated; the auth/audit is real.
* POST /api/demo/tool-call (step 3): runs a mock calendar tool call through the authorization engine.
* The tool surface is simulated; the auth and audit are real.
*/

import { generateId } from "@glinr/theauth";
Expand All @@ -10,7 +9,6 @@ import { getSessionId } from "@/lib/cookie";
import { getSession, setSession } from "@/lib/session-store";
import { getTheAuth } from "@/lib/theauth-instance";

// Mock calendar tool responses
const MOCK_TOOLS: Record<string, (args: Record<string, unknown>) => unknown> = {
"calendar.list_events": (args) => ({
events: [
Expand Down Expand Up @@ -73,7 +71,6 @@ export async function POST(): Promise<NextResponse> {
return NextResponse.json({ error: "Complete step 2 first" }, { status: 400 });
}

// Determine which tool to call next in sequence
const callIndex = session.toolCalls.length;
if (callIndex >= TOOL_SEQUENCE.length) {
return NextResponse.json({ error: "All tool calls complete" }, { status: 400 });
Expand Down Expand Up @@ -104,7 +101,6 @@ export async function POST(): Promise<NextResponse> {

session.toolCalls.push(callRecord);

// Append a synthetic audit entry to the session's audit log
session.auditLog.push({
id: authResult.auditId || generateId(),
agentId: session.agentId ?? "unknown",
Expand Down
2 changes: 0 additions & 2 deletions apps/marquee-demo/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ export default function DemoPage() {
);
}

// Sub-components

interface PanelProps {
number: number;
title: string;
Expand Down
4 changes: 0 additions & 4 deletions apps/marquee-demo/src/lib/cookie.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/**
* Minimal cookie helpers for the demo session.
*/

import { cookies } from "next/headers";

const SESSION_COOKIE = "kdemo_sid";
Expand Down
6 changes: 2 additions & 4 deletions apps/marquee-demo/src/lib/session-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* In-memory session store keyed by session ID (set via cookie).
* State is per-browser. State is lost on cold start, acceptable for a demo.
* In-memory session store keyed by the session cookie. State is per process and lost on cold start, fine for a demo.
*/

export interface DemoAuditEntry {
Expand Down Expand Up @@ -39,8 +38,7 @@ export interface ToolCallRecord {
auditId: string;
}

// Global in-memory store, intentionally module-level so it persists across requests
// within a single server process. Fine for a demo; not suitable for production.
// Module-level so it persists across requests in one server process. Not suitable for production.
const store = new Map<string, DemoSession>();

export function getSession(id: string): DemoSession | undefined {
Expand Down
3 changes: 1 addition & 2 deletions apps/marquee-demo/src/lib/theauth-instance.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Singleton TheAuth instance for the marquee demo.
* Uses in-memory SQLite, state resets on cold start (acceptable for a demo).
* Singleton TheAuth instance for the demo. In-memory SQLite, so state resets on cold start.
*/

import type { TheAuth } from "@glinr/theauth";
Expand Down
20 changes: 1 addition & 19 deletions apps/marquee-demo/tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { expect, test } from "@playwright/test";

/**
* Full five-step demo scenario.
* Each assertion verifies that the panel reaches its green-check state in order.
* The final assertion confirms the reset button returns panel 1 to its initial state.
*
* Run with: pnpm --filter marquee-demo test:e2e
* Five-step demo scenario, checked panel by panel. Run with: pnpm --filter marquee-demo test:e2e
*/

const BASE = process.env.PLAYWRIGHT_BASE_URL ?? "http://localhost:3001";

test.describe("TheAuth marquee demo", () => {
test.beforeEach(async ({ page }) => {
// Clear any existing session before each test
await page.goto(BASE);
const resetBtn = page.getByTestId("reset-button");
if (await resetBtn.isVisible()) {
Expand All @@ -24,30 +19,25 @@ test.describe("TheAuth marquee demo", () => {
test("step 1, passkey sign-up", async ({ page }) => {
await page.goto(BASE);

// Panel 1 is visible and initially not done
const panel1 = page.getByTestId("panel-1");
await expect(panel1).toBeVisible();
await expect(panel1).toHaveAttribute("data-done", "false");

// Fill in username and sign up
await page.getByTestId("username-input").fill("Test User");
await page.getByTestId("signup-button").click();

// Panel 1 should reach done state
await expect(panel1).toHaveAttribute("data-done", "true", { timeout: 8000 });
});

test("step 2, spawn agent", async ({ page }) => {
await page.goto(BASE);

// Complete step 1
await page.getByTestId("username-input").fill("Test User");
await page.getByTestId("signup-button").click();
await expect(page.getByTestId("panel-1")).toHaveAttribute("data-done", "true", {
timeout: 8000,
});

// Spawn agent
await page.getByTestId("spawn-agent-button").click();
await expect(page.getByTestId("panel-2")).toHaveAttribute("data-done", "true", {
timeout: 8000,
Expand All @@ -68,18 +58,15 @@ test.describe("TheAuth marquee demo", () => {
timeout: 8000,
});

// Make three tool calls
for (let i = 0; i < 3; i++) {
await page.getByTestId("tool-call-button").click();
// Brief wait between calls
await page.waitForTimeout(500);
}

await expect(page.getByTestId("panel-3")).toHaveAttribute("data-done", "true", {
timeout: 10000,
});

// Audit entries should be present
const auditEntries = page.getByTestId("audit-entry");
await expect(auditEntries).toHaveCount(3, { timeout: 8000 });
});
Expand Down Expand Up @@ -139,7 +126,6 @@ test.describe("TheAuth marquee demo", () => {
timeout: 8000,
});

// Export, verify download
const downloadPromise = page.waitForEvent("download");
await page.getByTestId("export-button").click();
const download = await downloadPromise;
Expand All @@ -153,22 +139,18 @@ test.describe("TheAuth marquee demo", () => {
test("reset button clears state, panel 1 returns to initial", async ({ page }) => {
await page.goto(BASE);

// Complete step 1
await page.getByTestId("username-input").fill("Test User");
await page.getByTestId("signup-button").click();
await expect(page.getByTestId("panel-1")).toHaveAttribute("data-done", "true", {
timeout: 8000,
});

// Reset
await page.getByTestId("reset-button").click();

// Panel 1 should be back to initial (not done)
await expect(page.getByTestId("panel-1")).toHaveAttribute("data-done", "false", {
timeout: 5000,
});

// Input should be available again
await expect(page.getByTestId("username-input")).toBeEnabled({ timeout: 5000 });
});
});
58 changes: 58 additions & 0 deletions apps/playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="color-scheme" content="dark light" />
<meta name="description" content="Run the real theAuth taint guard and policy engine in your browser and verify a signed audit receipt." />
<title>theAuth Playground</title>
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<header class="top">
<h1>theAuth playground</h1>
<p>The real taint guard, policy engine and signed audit receipts, running in this tab. No server.</p>
</header>
<main id="main" tabindex="-1">
<section aria-labelledby="h-scenario" class="card">
<h2 id="h-scenario">1. Pick a scenario</h2>
<p class="muted">An agent has three tools: <code>send_email</code>, <code>read_web</code> and <code>pay</code>.</p>
<div id="presets" role="radiogroup" aria-label="Scenario presets" class="presets"></div>
<p id="preset-desc" class="muted" aria-live="polite"></p>
</section>

<section aria-labelledby="h-policy" class="card">
<h2 id="h-policy">2. Policy</h2>
<label for="policy">Policy JSON (editable). <code>taint.rules</code> and <code>risk.tiers</code> are passed to <code>createTheAuth</code> as <code>policy.taint</code> and <code>policy.risk</code>.</label>
<textarea id="policy" spellcheck="false" rows="16" autocomplete="off"></textarea>
<p id="policy-error" class="error" role="alert"></p>
<div class="row">
<button id="run" type="button" class="primary">Run the tool call</button>
<button id="reset" type="button">Reset policy</button>
</div>
</section>

<section aria-labelledby="h-result" class="card" aria-live="polite">
<h2 id="h-result">3. Decision</h2>
<div id="result"><p class="muted">Run a scenario to see the guard decision.</p></div>
</section>

<section aria-labelledby="h-receipt" class="card" aria-live="polite">
<h2 id="h-receipt">4. Signed audit receipt</h2>
<div id="receipt"><p class="muted">The receipt appears after a run.</p></div>
</section>

<section aria-labelledby="h-code" class="card">
<h2 id="h-code">5. The same thing in your code</h2>
<!-- biome-ignore lint/a11y/useAriaPropsSupportedByRole: labelled scroll region for keyboard users -->
<!-- biome-ignore lint/a11y/noNoninteractiveTabindex: keyboard users must be able to scroll the code -->
<pre id="code" class="code" tabindex="0" aria-label="Generated guardTool snippet"></pre>

Check warning on line 49 in apps/playground/index.html

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

"tabindex" should only be declared on interactive elements.

See more on https://sonarcloud.io/project/issues?id=glincker_theauth&issues=AaFIS0u9W1pCEb9gxYsR&open=AaFIS0u9W1pCEb9gxYsR&pullRequest=256
<div class="row">
<button id="copy" type="button">Copy code</button>
<span id="copy-status" class="muted" role="status"></span>

Check warning on line 52 in apps/playground/index.html

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use <output> instead of the status role to ensure accessibility across all devices.

See more on https://sonarcloud.io/project/issues?id=glincker_theauth&issues=AaFIS0u9W1pCEb9gxYsS&open=AaFIS0u9W1pCEb9gxYsS&pullRequest=256
</div>
</section>
</main>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions apps/playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "playground",
"version": "0.1.0",
"private": true,
"type": "module",
"description": "Static in-browser playground for the theAuth taint guard, policy engine and signed audit receipts",
"scripts": {
"dev": "vite",
"build": "tsc --noEmit && vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit",
"test": "vitest run"
},
"dependencies": {
"@glinr/theauth": "workspace:*",
"sql.js": "^1.14.1"
},
"devDependencies": {
"@types/sql.js": "^1.4.11",
"typescript": "^6.0.3",
"vite": "^7.3.7",
"vitest": "^4.1.11"
}
}
8 changes: 8 additions & 0 deletions apps/playground/src/edge/sql-js.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Browser sql.js loader handed to `createTheAuth({ sqlJs })`. The default init cannot find
// the .wasm file in a browser, so this points it at the file Vite bundles.
import initSqlJs from "sql.js/dist/sql-wasm-browser.js";
import wasmUrl from "sql.js/dist/sql-wasm-browser.wasm?url";

export function loadSqlJs() {
return initSqlJs({ locateFile: () => wasmUrl });
}
6 changes: 6 additions & 0 deletions apps/playground/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// <reference types="vite/client" />

declare module "sql.js/dist/sql-wasm-browser.js" {
import initSqlJs from "sql.js";
export default initSqlJs;
}
Loading
Loading