@@ -23,24 +23,48 @@ export const AuthProvider = z.enum([
2323
2424export const SessionUserSchema = z . object ( {
2525 id : z . string ( ) . describe ( 'User ID' ) ,
26- username : z . string ( ) . describe ( 'Username' ) ,
2726 email : z . string ( ) . email ( ) . describe ( 'Email address' ) ,
27+ emailVerified : z . boolean ( ) . default ( false ) . describe ( 'Is email verified?' ) ,
2828 name : z . string ( ) . describe ( 'Display name' ) ,
29- roles : z . array ( z . string ( ) ) . describe ( 'Assigned role IDs' ) ,
30- tenantId : z . string ( ) . describe ( 'Current tenant ID' ) ,
31- avatar : z . string ( ) . optional ( ) . describe ( 'Avatar URL' ) ,
29+ image : z . string ( ) . optional ( ) . describe ( 'Avatar URL' ) ,
30+ username : z . string ( ) . optional ( ) . describe ( 'Username (optional)' ) ,
31+ roles : z . array ( z . string ( ) ) . optional ( ) . default ( [ ] ) . describe ( 'Assigned role IDs' ) ,
32+ tenantId : z . string ( ) . optional ( ) . describe ( 'Current tenant ID' ) ,
3233 language : z . string ( ) . default ( 'en' ) . describe ( 'Preferred language' ) ,
3334 timezone : z . string ( ) . optional ( ) . describe ( 'Preferred timezone' ) ,
35+ createdAt : z . date ( ) . optional ( ) ,
36+ updatedAt : z . date ( ) . optional ( ) ,
37+ } ) ;
38+
39+ export const SessionSchema = z . object ( {
40+ id : z . string ( ) ,
41+ expiresAt : z . date ( ) ,
42+ token : z . string ( ) . optional ( ) ,
43+ ipAddress : z . string ( ) . optional ( ) ,
44+ userAgent : z . string ( ) . optional ( ) ,
45+ userId : z . string ( ) ,
3446} ) ;
3547
3648// ==========================================
3749// Requests
3850// ==========================================
3951
52+ export const LoginType = z . enum ( [ 'email' , 'username' , 'phone' , 'magic-link' , 'social' ] ) ;
53+
4054export const LoginRequestSchema = z . object ( {
41- username : z . string ( ) . describe ( 'Username or Email' ) ,
42- password : z . string ( ) . describe ( 'Password credential' ) ,
43- type : z . literal ( 'password' ) . default ( 'password' ) ,
55+ type : LoginType . default ( 'email' ) . describe ( 'Login method' ) ,
56+ email : z . string ( ) . email ( ) . optional ( ) . describe ( 'Required for email/magic-link' ) ,
57+ username : z . string ( ) . optional ( ) . describe ( 'Required for username login' ) ,
58+ password : z . string ( ) . optional ( ) . describe ( 'Required for password login' ) ,
59+ provider : z . string ( ) . optional ( ) . describe ( 'Required for social (google, github)' ) ,
60+ redirectTo : z . string ( ) . optional ( ) . describe ( 'Redirect URL after successful login' ) ,
61+ } ) ;
62+
63+ export const RegisterRequestSchema = z . object ( {
64+ email : z . string ( ) . email ( ) ,
65+ password : z . string ( ) ,
66+ name : z . string ( ) ,
67+ image : z . string ( ) . optional ( ) ,
4468} ) ;
4569
4670export const RefreshTokenRequestSchema = z . object ( {
@@ -53,10 +77,9 @@ export const RefreshTokenRequestSchema = z.object({
5377
5478export const SessionResponseSchema = BaseResponseSchema . extend ( {
5579 data : z . object ( {
56- accessToken : z . string ( ) . describe ( 'JWT Access Token' ) ,
57- refreshToken : z . string ( ) . optional ( ) . describe ( 'Refresh Token (if enabled)' ) ,
58- expiresIn : z . number ( ) . describe ( 'Token expiry in seconds' ) ,
59- user : SessionUserSchema . describe ( 'Current user details' ) ,
80+ session : SessionSchema . describe ( 'Active Session Info' ) ,
81+ user : SessionUserSchema . describe ( 'Current User Details' ) ,
82+ token : z . string ( ) . optional ( ) . describe ( 'Bearer token if not using cookies' ) ,
6083 } ) ,
6184} ) ;
6285
0 commit comments