- Add license activation flow: server validates/activates keys via Polar SDK - Auto-activate from Polar checkout redirect (checkout_id in URL) - Gate dashboard behind license activation (redirect to /activate if no plan) - Preserve redirect URL through login flow for post-purchase activation - Show plan status badge in sidebar and overview page - Add account section to settings (email, plan, license key) - Add svelte-sonner toasts with custom black theme and iconify icons - Improve validation messages across all forms - Update API key prefix to droidclaw_ - Add cursor pointer globally for clickable elements - Support Polar sandbox mode via POLAR_SANDBOX env flag
27 lines
801 B
TypeScript
27 lines
801 B
TypeScript
import { form, getRequestEvent, query } from '$app/server';
|
|
import { auth } from '$lib/server/auth';
|
|
import { createKeySchema, deleteKeySchema } from '$lib/schema/api-keys';
|
|
|
|
export const listKeys = query(async () => {
|
|
const { request } = getRequestEvent();
|
|
return await auth.api.listApiKeys({ headers: request.headers });
|
|
});
|
|
|
|
export const createKey = form(createKeySchema, async ({ name }) => {
|
|
const { request } = getRequestEvent();
|
|
const result = await auth.api.createApiKey({
|
|
body: { name, prefix: 'droidclaw_' },
|
|
headers: request.headers
|
|
});
|
|
return result;
|
|
});
|
|
|
|
export const deleteKey = form(deleteKeySchema, async ({ keyId }) => {
|
|
const { request } = getRequestEvent();
|
|
await auth.api.deleteApiKey({
|
|
body: { keyId },
|
|
headers: request.headers
|
|
});
|
|
return { deleted: true };
|
|
});
|