@ereo/auth 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # @ereo/auth
2
+
3
+ Authentication plugin for the EreoJS framework. Provides authentication and authorization with multiple providers, JWT/cookie-based sessions, and role-based access control.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @ereo/auth
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { defineConfig } from '@ereo/core';
15
+ import { createAuthPlugin, credentials, github } from '@ereo/auth';
16
+
17
+ export default defineConfig({
18
+ plugins: [
19
+ createAuthPlugin({
20
+ session: {
21
+ secret: process.env.AUTH_SECRET!,
22
+ strategy: 'jwt',
23
+ maxAge: 7 * 24 * 60 * 60, // 7 days
24
+ },
25
+ providers: [
26
+ credentials({
27
+ authorize: async ({ email, password }) => {
28
+ // Validate credentials and return user
29
+ const user = await db.users.findByEmail(email);
30
+ if (user && await bcrypt.compare(password, user.passwordHash)) {
31
+ return { id: user.id, email: user.email, roles: user.roles };
32
+ }
33
+ return null;
34
+ },
35
+ }),
36
+ github({
37
+ clientId: process.env.GITHUB_CLIENT_ID!,
38
+ clientSecret: process.env.GITHUB_CLIENT_SECRET!,
39
+ }),
40
+ ],
41
+ }),
42
+ ],
43
+ });
44
+ ```
45
+
46
+ ## Using Auth in Routes
47
+
48
+ ```typescript
49
+ import { useAuth, requireAuth, getSession, getUser } from '@ereo/auth';
50
+
51
+ // Protect route with requireAuth
52
+ export const config = {
53
+ ...requireAuth({ redirect: '/login' }),
54
+ };
55
+
56
+ // Access auth in loader/action
57
+ export async function loader({ context }) {
58
+ const auth = useAuth(context);
59
+
60
+ if (auth.isAuthenticated()) {
61
+ return { user: auth.getUser() };
62
+ }
63
+
64
+ return { user: null };
65
+ }
66
+
67
+ // Sign in
68
+ export async function action({ request, context }) {
69
+ const auth = useAuth(context);
70
+ const formData = await request.formData();
71
+
72
+ const session = await auth.signIn('credentials', {
73
+ email: formData.get('email'),
74
+ password: formData.get('password'),
75
+ });
76
+
77
+ return new Response(null, {
78
+ status: 302,
79
+ headers: {
80
+ Location: '/dashboard',
81
+ 'Set-Cookie': auth.getCookieHeader()!,
82
+ },
83
+ });
84
+ }
85
+ ```
86
+
87
+ ## Features
88
+
89
+ - **Multiple Auth Providers**: `credentials()`, `github()`, `google()`, `discord()`, `oauth()`, `apiKey()`, `mock()`
90
+ - **Session Strategies**: JWT (stateless), cookie (server-side), or hybrid
91
+ - **Role-Based Access Control**: `hasRole()`, `hasAnyRole()`, `hasAllRoles()`
92
+ - **Route Protection**: `requireAuth()`, `requireRoles()`, `optionalAuth()`, `withAuth()`
93
+ - **Session Callbacks**: `onSessionCreated`, `onSessionValidate`, `onSignIn`, `onSignOut`, `jwt`, `session`
94
+ - **Cookie Configuration**: Secure defaults with full customization
95
+ - **TypeScript Support**: Full type safety with exported interfaces
96
+
97
+ ## Exports
98
+
99
+ ```typescript
100
+ // Plugin and utilities
101
+ import {
102
+ createAuthPlugin,
103
+ requireAuth,
104
+ optionalAuth,
105
+ requireRoles,
106
+ useAuth,
107
+ getSession,
108
+ getUser,
109
+ withAuth,
110
+ getOAuthUrl,
111
+ handleOAuthCallback,
112
+ } from '@ereo/auth';
113
+
114
+ // Providers
115
+ import {
116
+ credentials,
117
+ github,
118
+ google,
119
+ discord,
120
+ oauth,
121
+ mock,
122
+ apiKey,
123
+ } from '@ereo/auth';
124
+
125
+ // Types
126
+ import type {
127
+ User,
128
+ Session,
129
+ JWTPayload,
130
+ AuthProvider,
131
+ SessionStrategy,
132
+ SessionConfig,
133
+ AuthConfig,
134
+ AuthContext,
135
+ } from '@ereo/auth';
136
+ ```
137
+
138
+ ## AuthContext Methods
139
+
140
+ | Method | Description |
141
+ |--------|-------------|
142
+ | `session` | Current session object or null |
143
+ | `signIn(provider, credentials)` | Sign in with provider |
144
+ | `signOut()` | Sign out current user |
145
+ | `isAuthenticated()` | Check if authenticated |
146
+ | `hasRole(role)` | Check for specific role |
147
+ | `hasAnyRole(roles)` | Check for any of the roles |
148
+ | `hasAllRoles(roles)` | Check for all roles |
149
+ | `getUser()` | Get current user object |
150
+ | `getToken()` | Get JWT token |
151
+ | `refreshSession()` | Refresh session expiration |
152
+ | `getCookieHeader()` | Get Set-Cookie header for response |
153
+
154
+ ## Session Strategies
155
+
156
+ | Strategy | Description |
157
+ |----------|-------------|
158
+ | `'jwt'` | Stateless - session data in signed JWT |
159
+ | `'cookie'` | Server-side - session ID in cookie, data in memory |
160
+ | `'hybrid'` | JWT with server-side validation for revocation |
161
+
162
+ ## Documentation
163
+
164
+ For full documentation, see [Auth Plugin API Reference](https://ereojs.dev/docs/api/plugins/auth).
165
+
166
+ ## Part of EreoJS
167
+
168
+ This package is part of the [EreoJS](https://github.com/ereojs/ereo) monorepo - a modern full-stack JavaScript framework.
169
+
170
+ ## License
171
+
172
+ MIT
package/dist/auth.d.ts ADDED
@@ -0,0 +1,220 @@
1
+ /**
2
+ * @ereo/auth - Authentication plugin for EreoJS framework
3
+ *
4
+ * Provides authentication and authorization with multiple providers,
5
+ * JWT-based sessions, and role-based access control.
6
+ */
7
+ import type { Plugin, RouteConfig, AppContext } from '@ereo/core';
8
+ /** User data returned from auth providers */
9
+ export interface User {
10
+ /** User ID */
11
+ id: string;
12
+ /** User email */
13
+ email?: string;
14
+ /** User name */
15
+ name?: string;
16
+ /** User roles for RBAC */
17
+ roles?: string[];
18
+ /** Custom user data */
19
+ [key: string]: unknown;
20
+ }
21
+ /** User session data */
22
+ export interface Session {
23
+ /** User ID */
24
+ userId: string;
25
+ /** User email */
26
+ email?: string;
27
+ /** User name */
28
+ name?: string;
29
+ /** User roles */
30
+ roles?: string[];
31
+ /** Custom claims */
32
+ claims?: Record<string, unknown>;
33
+ /** Session expiration */
34
+ expiresAt?: Date;
35
+ /** Session ID for in-memory tracking */
36
+ sessionId?: string;
37
+ /** Issued at timestamp */
38
+ issuedAt?: Date;
39
+ /** Provider used for authentication */
40
+ provider?: string;
41
+ }
42
+ /** JWT payload structure */
43
+ export interface JWTPayload {
44
+ /** Subject (user ID) */
45
+ sub: string;
46
+ /** Issued at (Unix timestamp) */
47
+ iat: number;
48
+ /** Expiration (Unix timestamp) */
49
+ exp: number;
50
+ /** Session ID */
51
+ sid?: string;
52
+ /** Custom claims */
53
+ [key: string]: unknown;
54
+ }
55
+ /** Authentication provider configuration */
56
+ export interface AuthProvider {
57
+ /** Provider ID */
58
+ id: string;
59
+ /** Provider name */
60
+ name: string;
61
+ /** Provider type */
62
+ type: 'credentials' | 'oauth';
63
+ /** Authorize/authenticate user */
64
+ authorize(credentials: Record<string, unknown>): Promise<User | null>;
65
+ /** Get OAuth authorization URL (for OAuth providers) */
66
+ getAuthorizationUrl?(state: string, redirectUri: string): string;
67
+ /** Handle OAuth callback (for OAuth providers) */
68
+ handleCallback?(params: {
69
+ code: string;
70
+ state: string;
71
+ redirectUri: string;
72
+ }): Promise<User | null>;
73
+ }
74
+ /** Session strategy type */
75
+ export type SessionStrategy = 'jwt' | 'cookie' | 'hybrid';
76
+ /** Session configuration */
77
+ export interface SessionConfig {
78
+ /** Session strategy: 'jwt', 'cookie', or 'hybrid' */
79
+ strategy?: SessionStrategy;
80
+ /** Session max age in seconds (default: 7 days) */
81
+ maxAge?: number;
82
+ /** Secret for signing JWT/cookies */
83
+ secret: string;
84
+ /** Session update age - refresh session if older than this (seconds) */
85
+ updateAge?: number;
86
+ }
87
+ /** Auth plugin configuration */
88
+ export interface AuthConfig {
89
+ /** Session secret for signing cookies/JWT (deprecated, use session.secret) */
90
+ secret?: string;
91
+ /** Session duration in seconds (deprecated, use session.maxAge) */
92
+ sessionDuration?: number;
93
+ /** Authentication providers */
94
+ providers?: AuthProvider[];
95
+ /** Session configuration */
96
+ session?: SessionConfig;
97
+ /** Callbacks for customization */
98
+ callbacks?: {
99
+ /** Called when session is created */
100
+ onSessionCreated?: (session: Session) => Promise<Session> | Session;
101
+ /** Called to validate session */
102
+ onSessionValidate?: (session: Session) => Promise<boolean> | boolean;
103
+ /** Called when user signs in */
104
+ onSignIn?: (user: User) => Promise<void> | void;
105
+ /** Called when user signs out */
106
+ onSignOut?: (session: Session) => Promise<void> | void;
107
+ /** Called to generate JWT payload from session */
108
+ jwt?: (params: {
109
+ token: JWTPayload;
110
+ user?: User;
111
+ session?: Session;
112
+ }) => Promise<JWTPayload> | JWTPayload;
113
+ /** Called to generate session from JWT payload */
114
+ session?: (params: {
115
+ token: JWTPayload;
116
+ session: Session;
117
+ }) => Promise<Session> | Session;
118
+ };
119
+ /** Cookie configuration */
120
+ cookie?: {
121
+ name?: string;
122
+ secure?: boolean;
123
+ sameSite?: 'strict' | 'lax' | 'none';
124
+ domain?: string;
125
+ path?: string;
126
+ httpOnly?: boolean;
127
+ };
128
+ /** Debug mode */
129
+ debug?: boolean;
130
+ }
131
+ /** Auth context added to request context */
132
+ export interface AuthContext {
133
+ /** Current session (if authenticated) */
134
+ session: Session | null;
135
+ /** Sign in with credentials */
136
+ signIn: (provider: string, credentials: Record<string, unknown>) => Promise<Session>;
137
+ /** Sign out current user */
138
+ signOut: () => Promise<void>;
139
+ /** Check if user is authenticated */
140
+ isAuthenticated: () => boolean;
141
+ /** Check if user has role */
142
+ hasRole: (role: string) => boolean;
143
+ /** Check if user has any of the roles */
144
+ hasAnyRole: (roles: string[]) => boolean;
145
+ /** Check if user has all of the roles */
146
+ hasAllRoles: (roles: string[]) => boolean;
147
+ /** Get the current user */
148
+ getUser: () => User | null;
149
+ /** Get session token (JWT) */
150
+ getToken: () => Promise<string | null>;
151
+ /** Refresh the session */
152
+ refreshSession: () => Promise<Session | null>;
153
+ /** Get Set-Cookie header value for response */
154
+ getCookieHeader: () => string | null;
155
+ }
156
+ /** Create the auth plugin */
157
+ export declare function createAuthPlugin(config: AuthConfig): Plugin;
158
+ /**
159
+ * Create auth middleware for route protection.
160
+ */
161
+ export declare function requireAuth(options?: {
162
+ redirect?: string;
163
+ roles?: string[];
164
+ permissions?: string[];
165
+ unauthorizedResponse?: {
166
+ status: number;
167
+ body: unknown;
168
+ };
169
+ }): Partial<RouteConfig>;
170
+ /**
171
+ * Create optional auth middleware (allows anonymous but adds auth context).
172
+ */
173
+ export declare function optionalAuth(): Partial<RouteConfig>;
174
+ /**
175
+ * Create role-based auth middleware.
176
+ */
177
+ export declare function requireRoles(roles: string[], options?: {
178
+ redirect?: string;
179
+ requireAll?: boolean;
180
+ }): Partial<RouteConfig>;
181
+ /**
182
+ * Helper to use auth in loaders/actions.
183
+ */
184
+ export declare function useAuth(context: AppContext): AuthContext;
185
+ /**
186
+ * Get the current session from context (or null if not authenticated).
187
+ */
188
+ export declare function getSession(context: AppContext): Session | null;
189
+ /**
190
+ * Get the current user from context (or null if not authenticated).
191
+ */
192
+ export declare function getUser(context: AppContext): User | null;
193
+ /**
194
+ * Create a protected route handler that requires authentication.
195
+ */
196
+ export declare function withAuth<T>(handler: (args: {
197
+ request: Request;
198
+ context: AppContext;
199
+ auth: AuthContext;
200
+ params: Record<string, string>;
201
+ }) => T | Promise<T>, options?: {
202
+ roles?: string[];
203
+ }): (args: {
204
+ request: Request;
205
+ context: AppContext;
206
+ params: Record<string, string>;
207
+ }) => Promise<T>;
208
+ /**
209
+ * Get OAuth authorization URL for a provider.
210
+ */
211
+ export declare function getOAuthUrl(context: AppContext, providerId: string, redirectUri: string): string;
212
+ /**
213
+ * Handle OAuth callback.
214
+ */
215
+ export declare function handleOAuthCallback(context: AppContext, providerId: string, params: {
216
+ code: string;
217
+ state: string;
218
+ redirectUri: string;
219
+ }): Promise<Session>;
220
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAmC,MAAM,YAAY,CAAC;AAMnG,6CAA6C;AAC7C,MAAM,WAAW,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AC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC3D,OAAO,CAAC,OAAO,CAAC,CAgBlB"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @ereo/auth - Authentication plugin for EreoJS framework
3
+ *
4
+ * Provides complete authentication and authorization with:
5
+ * - Multiple auth providers (credentials, OAuth)
6
+ * - JWT-based session management
7
+ * - Cookie-based session management
8
+ * - Role-based access control (RBAC)
9
+ * - Protected routes middleware
10
+ */
11
+ export { createAuthPlugin, requireAuth, optionalAuth, requireRoles, useAuth, getSession, getUser, withAuth, getOAuthUrl, handleOAuthCallback, } from './auth';
12
+ export type { User, Session, JWTPayload, AuthProvider, SessionStrategy, SessionConfig, AuthConfig, AuthContext, } from './auth';
13
+ export { credentials, github, google, discord, oauth, mock, apiKey, } from './providers/index';
14
+ export type { CredentialsConfig, OAuthConfig, GitHubConfig, GoogleConfig, DiscordConfig, GenericOAuthConfig, OAuthTokens, MockConfig, ApiKeyConfig, } from './providers/index';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EACX,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAGhB,YAAY,EACV,IAAI,EACJ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,WAAW,GACZ,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,GACP,MAAM,mBAAmB,CAAC;AAG3B,YAAY,EACV,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,mBAAmB,CAAC"}