mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
split schema for server functions
This commit is contained in:
@@ -11,5 +11,4 @@
|
|||||||
- generate state and check it against the state returned from lichess https://lichess.org/api#tag/oauth/GET/oauth
|
- generate state and check it against the state returned from lichess https://lichess.org/api#tag/oauth/GET/oauth
|
||||||
- checkbox and toggle disabled states
|
- checkbox and toggle disabled states
|
||||||
- 404 page
|
- 404 page
|
||||||
- lichess data with zod validation
|
|
||||||
- react query on for study and chapter load, to allow caching
|
- react query on for study and chapter load, to allow caching
|
||||||
@@ -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
@@ -9,26 +9,11 @@ import {
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { env } from "#/env.ts";
|
import { env } from "#/env.ts";
|
||||||
import { base64UrlEncode, sha256 } from "#/lib/encodeDecode.ts";
|
import { base64UrlEncode, sha256 } from "#/lib/encodeDecode.ts";
|
||||||
|
import {
|
||||||
export const SessionSchema = z.object({
|
LichessAccountSchema,
|
||||||
username: z.string(),
|
SessionSchema,
|
||||||
id: z.string(),
|
TokenResponseSchema,
|
||||||
token: z.string(),
|
} from "#/schemas.ts";
|
||||||
});
|
|
||||||
|
|
||||||
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>;
|
|
||||||
|
|
||||||
const createVerifier = () => base64UrlEncode(randomBytes(32));
|
const createVerifier = () => base64UrlEncode(randomBytes(32));
|
||||||
const createChallenge = (verifier: string) => base64UrlEncode(sha256(verifier));
|
const createChallenge = (verifier: string) => base64UrlEncode(sha256(verifier));
|
||||||
|
|||||||
Reference in New Issue
Block a user