split schema for server functions

This commit is contained in:
2026-06-12 11:04:43 +02:00
parent 0b32e77d7e
commit 3da81680a1
3 changed files with 24 additions and 21 deletions
-1
View File
@@ -11,5 +11,4 @@
- generate state and check it against the state returned from lichess https://lichess.org/api#tag/oauth/GET/oauth
- checkbox and toggle disabled states
- 404 page
- lichess data with zod validation
- react query on for study and chapter load, to allow caching
+19
View File
@@ -0,0 +1,19 @@
import { z } from "zod";
export const SessionSchema = z.object({
username: z.string(),
id: z.string(),
token: z.string(),
});
export const TokenResponseSchema = z.object({
access_token: z.string(),
expires_in: z.number().optional(),
scope: z.string().optional(),
token_type: z.string().optional(),
});
export const LichessAccountSchema = z.object({
id: z.string(),
username: z.string(),
});
+5 -20
View File
@@ -9,26 +9,11 @@ import {
import { z } from "zod";
import { env } from "#/env.ts";
import { base64UrlEncode, sha256 } from "#/lib/encodeDecode.ts";
export const SessionSchema = z.object({
username: z.string(),
id: z.string(),
token: z.string(),
});
const TokenResponseSchema = z.object({
access_token: z.string(),
expires_in: z.number().optional(),
scope: z.string().optional(),
token_type: z.string().optional(),
});
const LichessAccountSchema = z.object({
id: z.string(),
username: z.string(),
});
// export type Session = z.infer<typeof SessionSchema>;
import {
LichessAccountSchema,
SessionSchema,
TokenResponseSchema,
} from "#/schemas.ts";
const createVerifier = () => base64UrlEncode(randomBytes(32));
const createChallenge = (verifier: string) => base64UrlEncode(sha256(verifier));