feat: implement automation key management with middleware and routes for organization API keys, invite improvements

This commit is contained in:
Rotimi Best
2026-03-13 18:40:07 +01:00
parent 77a1188573
commit 492f8dc5ed
71 changed files with 3655 additions and 456 deletions
@@ -0,0 +1,29 @@
import { Context, Next } from 'hono';
import { authMiddleware } from './auth';
import { automationKeyMiddleware } from './automation-key';
export const authOrAutomationKeyMiddleware = async (c: Context, next: Next) => {
const user = c.get('user');
const session = c.get('session');
if (user && session) {
c.set('automationKey', null);
await authMiddleware(c, next);
return;
}
const authHeader = c.req.header('Authorization');
if (authHeader?.startsWith('Bearer ')) {
return automationKeyMiddleware(c, next);
}
return c.json(
{
success: false,
message: 'Unauthorized: Authentication required (session or automation key)'
},
401
);
};