zeno

Elysia Integration

import { Elysia } from 'elysia';

const ZENO_VERIFY_URL = '[https://zeno.secops.workers.dev/api/verify](https://zeno.secops.workers.dev/api/verify)';
const SITE_KEY = 'YOUR_SITE_KEY';

const zeno = (app: Elysia) => app.decorate('verifyZeno', async (token: string) => {
    const response = await fetch(ZENO_VERIFY_URL, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ 
            token,
            site_key: SITE_KEY 
        })
    });
    const data = await response.json();
    return data.valid;
});

new Elysia()
    .use(zeno)
    .post('/login', async ({ body, verifyZeno, error }) => {
        if (!await verifyZeno(body.token)) return error(403, 'Invalid Captcha');
        return { success: true };
    })
    .listen(3000);