aboutsummaryrefslogtreecommitdiffhomepage
path: root/pkgs/shared
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-12-03 05:45:41 +0900
committernsfisis <nsfisis@gmail.com>2025-12-04 23:26:30 +0900
commit0763153865e2157e0d06c946993dd8b235b06c83 (patch)
tree8da68ed2e9c16bf121d59eae02e19b99f7f11fdc /pkgs/shared
parentf44390286378860b535e37ad045cb374a07aff5c (diff)
downloadkioku-0763153865e2157e0d06c946993dd8b235b06c83.tar.gz
kioku-0763153865e2157e0d06c946993dd8b235b06c83.tar.zst
kioku-0763153865e2157e0d06c946993dd8b235b06c83.zip
feat(auth): add refresh token endpoint
Implement refresh token functionality for authentication: - Add refresh_tokens table to database schema with user reference - Generate migration for the new table - Login endpoint now returns both access token and refresh token - Add POST /api/auth/refresh endpoint with token rotation - Refresh tokens are hashed (SHA256) before storage for security - Tokens expire after 7 days, access tokens after 15 minutes - Update tests to cover new functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'pkgs/shared')
-rw-r--r--pkgs/shared/src/schemas/index.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkgs/shared/src/schemas/index.ts b/pkgs/shared/src/schemas/index.ts
index 28b5f55..05b926a 100644
--- a/pkgs/shared/src/schemas/index.ts
+++ b/pkgs/shared/src/schemas/index.ts
@@ -37,6 +37,11 @@ export const loginSchema = z.object({
password: z.string().min(1),
});
+// Refresh token input schema
+export const refreshTokenSchema = z.object({
+ refreshToken: z.string().min(1),
+});
+
// Deck schema
export const deckSchema = z.object({
id: z.string().uuid(),
@@ -124,6 +129,7 @@ export const submitReviewSchema = z.object({
export type UserSchema = z.infer<typeof userSchema>;
export type CreateUserSchema = z.infer<typeof createUserSchema>;
export type LoginSchema = z.infer<typeof loginSchema>;
+export type RefreshTokenSchema = z.infer<typeof refreshTokenSchema>;
export type DeckSchema = z.infer<typeof deckSchema>;
export type CreateDeckSchema = z.infer<typeof createDeckSchema>;
export type UpdateDeckSchema = z.infer<typeof updateDeckSchema>;