@qwickapps/server 1.2.0 → 1.3.1
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 +392 -0
- package/dist/core/control-panel.d.ts +7 -2
- package/dist/core/control-panel.d.ts.map +1 -1
- package/dist/core/control-panel.js +120 -54
- package/dist/core/control-panel.js.map +1 -1
- package/dist/core/gateway.d.ts +159 -79
- package/dist/core/gateway.d.ts.map +1 -1
- package/dist/core/gateway.js +679 -319
- package/dist/core/gateway.js.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/plugin-registry.d.ts +307 -0
- package/dist/core/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugin-registry.js +352 -0
- package/dist/core/plugin-registry.js.map +1 -0
- package/dist/core/types.d.ts +16 -33
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts +14 -0
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js +179 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.js +51 -0
- package/dist/plugins/auth/adapters/basic-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/index.d.ts +10 -0
- package/dist/plugins/auth/adapters/index.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/index.js +10 -0
- package/dist/plugins/auth/adapters/index.js.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js +109 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.d.ts +18 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.js +267 -0
- package/dist/plugins/auth/adapters/supertokens-adapter.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.d.ts +40 -0
- package/dist/plugins/auth/auth-plugin.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.js +255 -0
- package/dist/plugins/auth/auth-plugin.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts +9 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.js +147 -0
- package/dist/plugins/auth/auth-plugin.test.js.map +1 -0
- package/dist/plugins/auth/env-config.d.ts +88 -0
- package/dist/plugins/auth/env-config.d.ts.map +1 -0
- package/dist/plugins/auth/env-config.js +489 -0
- package/dist/plugins/auth/env-config.js.map +1 -0
- package/dist/plugins/auth/index.d.ts +14 -0
- package/dist/plugins/auth/index.d.ts.map +1 -0
- package/dist/plugins/auth/index.js +16 -0
- package/dist/plugins/auth/index.js.map +1 -0
- package/dist/plugins/auth/supertokens-adapter.test.d.ts +10 -0
- package/dist/plugins/auth/supertokens-adapter.test.d.ts.map +1 -0
- package/dist/plugins/auth/supertokens-adapter.test.js +486 -0
- package/dist/plugins/auth/supertokens-adapter.test.js.map +1 -0
- package/dist/plugins/auth/types.d.ts +218 -0
- package/dist/plugins/auth/types.d.ts.map +1 -0
- package/dist/plugins/auth/types.js +14 -0
- package/dist/plugins/auth/types.js.map +1 -0
- package/dist/plugins/bans/bans-plugin.d.ts +59 -0
- package/dist/plugins/bans/bans-plugin.d.ts.map +1 -0
- package/dist/plugins/bans/bans-plugin.js +428 -0
- package/dist/plugins/bans/bans-plugin.js.map +1 -0
- package/dist/plugins/bans/index.d.ts +9 -0
- package/dist/plugins/bans/index.d.ts.map +1 -0
- package/dist/plugins/bans/index.js +10 -0
- package/dist/plugins/bans/index.js.map +1 -0
- package/dist/plugins/bans/stores/index.d.ts +7 -0
- package/dist/plugins/bans/stores/index.d.ts.map +1 -0
- package/dist/plugins/bans/stores/index.js +7 -0
- package/dist/plugins/bans/stores/index.js.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts +29 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.js +132 -0
- package/dist/plugins/bans/stores/postgres-store.js.map +1 -0
- package/dist/plugins/bans/types.d.ts +128 -0
- package/dist/plugins/bans/types.d.ts.map +1 -0
- package/dist/plugins/bans/types.js +11 -0
- package/dist/plugins/bans/types.js.map +1 -0
- package/dist/plugins/cache-plugin.d.ts +14 -3
- package/dist/plugins/cache-plugin.d.ts.map +1 -1
- package/dist/plugins/cache-plugin.js +27 -7
- package/dist/plugins/cache-plugin.js.map +1 -1
- package/dist/plugins/cache-plugin.test.js +99 -32
- package/dist/plugins/cache-plugin.test.js.map +1 -1
- package/dist/plugins/config-plugin.d.ts +3 -2
- package/dist/plugins/config-plugin.d.ts.map +1 -1
- package/dist/plugins/config-plugin.js +17 -10
- package/dist/plugins/config-plugin.js.map +1 -1
- package/dist/plugins/diagnostics-plugin.d.ts +2 -2
- package/dist/plugins/diagnostics-plugin.d.ts.map +1 -1
- package/dist/plugins/diagnostics-plugin.js +17 -10
- package/dist/plugins/diagnostics-plugin.js.map +1 -1
- package/dist/plugins/entitlements/entitlements-plugin.d.ts +95 -0
- package/dist/plugins/entitlements/entitlements-plugin.d.ts.map +1 -0
- package/dist/plugins/entitlements/entitlements-plugin.js +707 -0
- package/dist/plugins/entitlements/entitlements-plugin.js.map +1 -0
- package/dist/plugins/entitlements/index.d.ts +12 -0
- package/dist/plugins/entitlements/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/index.js +16 -0
- package/dist/plugins/entitlements/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/index.d.ts +9 -0
- package/dist/plugins/entitlements/sources/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/index.js +9 -0
- package/dist/plugins/entitlements/sources/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts +29 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.js +169 -0
- package/dist/plugins/entitlements/sources/postgres-source.js.map +1 -0
- package/dist/plugins/entitlements/types.d.ts +232 -0
- package/dist/plugins/entitlements/types.d.ts.map +1 -0
- package/dist/plugins/entitlements/types.js +11 -0
- package/dist/plugins/entitlements/types.js.map +1 -0
- package/dist/plugins/frontend-app-plugin.d.ts +9 -3
- package/dist/plugins/frontend-app-plugin.d.ts.map +1 -1
- package/dist/plugins/frontend-app-plugin.js +14 -9
- package/dist/plugins/frontend-app-plugin.js.map +1 -1
- package/dist/plugins/health-plugin.d.ts +5 -2
- package/dist/plugins/health-plugin.d.ts.map +1 -1
- package/dist/plugins/health-plugin.js +20 -5
- package/dist/plugins/health-plugin.js.map +1 -1
- package/dist/plugins/index.d.ts +10 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +10 -2
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/logs-plugin.d.ts +3 -2
- package/dist/plugins/logs-plugin.d.ts.map +1 -1
- package/dist/plugins/logs-plugin.js +21 -12
- package/dist/plugins/logs-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.d.ts +3 -3
- package/dist/plugins/postgres-plugin.d.ts.map +1 -1
- package/dist/plugins/postgres-plugin.js +9 -7
- package/dist/plugins/postgres-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.test.js +50 -29
- package/dist/plugins/postgres-plugin.test.js.map +1 -1
- package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts +7 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.d.ts.map +1 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.js +215 -0
- package/dist/plugins/preferences/__tests__/deep-merge.test.js.map +1 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts +7 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.d.ts.map +1 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.js +265 -0
- package/dist/plugins/preferences/__tests__/preferences-plugin.test.js.map +1 -0
- package/dist/plugins/preferences/index.d.ts +12 -0
- package/dist/plugins/preferences/index.d.ts.map +1 -0
- package/dist/plugins/preferences/index.js +13 -0
- package/dist/plugins/preferences/index.js.map +1 -0
- package/dist/plugins/preferences/preferences-plugin.d.ts +39 -0
- package/dist/plugins/preferences/preferences-plugin.d.ts.map +1 -0
- package/dist/plugins/preferences/preferences-plugin.js +226 -0
- package/dist/plugins/preferences/preferences-plugin.js.map +1 -0
- package/dist/plugins/preferences/stores/index.d.ts +9 -0
- package/dist/plugins/preferences/stores/index.d.ts.map +1 -0
- package/dist/plugins/preferences/stores/index.js +9 -0
- package/dist/plugins/preferences/stores/index.js.map +1 -0
- package/dist/plugins/preferences/stores/postgres-store.d.ts +41 -0
- package/dist/plugins/preferences/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/preferences/stores/postgres-store.js +181 -0
- package/dist/plugins/preferences/stores/postgres-store.js.map +1 -0
- package/dist/plugins/preferences/types.d.ts +91 -0
- package/dist/plugins/preferences/types.d.ts.map +1 -0
- package/dist/plugins/preferences/types.js +10 -0
- package/dist/plugins/preferences/types.js.map +1 -0
- package/dist/plugins/users/__tests__/users-plugin.test.d.ts +9 -0
- package/dist/plugins/users/__tests__/users-plugin.test.d.ts.map +1 -0
- package/dist/plugins/users/__tests__/users-plugin.test.js +546 -0
- package/dist/plugins/users/__tests__/users-plugin.test.js.map +1 -0
- package/dist/plugins/users/index.d.ts +12 -0
- package/dist/plugins/users/index.d.ts.map +1 -0
- package/dist/plugins/users/index.js +13 -0
- package/dist/plugins/users/index.js.map +1 -0
- package/dist/plugins/users/stores/index.d.ts +7 -0
- package/dist/plugins/users/stores/index.d.ts.map +1 -0
- package/dist/plugins/users/stores/index.js +7 -0
- package/dist/plugins/users/stores/index.js.map +1 -0
- package/dist/plugins/users/stores/postgres-store.d.ts +28 -0
- package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/users/stores/postgres-store.js +157 -0
- package/dist/plugins/users/stores/postgres-store.js.map +1 -0
- package/dist/plugins/users/types.d.ts +225 -0
- package/dist/plugins/users/types.d.ts.map +1 -0
- package/dist/plugins/users/types.js +12 -0
- package/dist/plugins/users/types.js.map +1 -0
- package/dist/plugins/users/users-plugin.d.ts +45 -0
- package/dist/plugins/users/users-plugin.d.ts.map +1 -0
- package/dist/plugins/users/users-plugin.js +359 -0
- package/dist/plugins/users/users-plugin.js.map +1 -0
- package/dist-ui/assets/index-BY8OxNgO.js +465 -0
- package/dist-ui/assets/index-BY8OxNgO.js.map +1 -0
- package/dist-ui/index.html +1 -1
- package/dist-ui-lib/api/controlPanelApi.d.ts +278 -0
- package/dist-ui-lib/components/ControlPanelApp.d.ts +61 -0
- package/dist-ui-lib/components/index.d.ts +18 -0
- package/dist-ui-lib/config/AppConfig.d.ts +7 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRegistry.d.ts +62 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRenderer.d.ts +8 -0
- package/dist-ui-lib/dashboard/PluginWidgetRenderer.d.ts +19 -0
- package/dist-ui-lib/dashboard/WidgetComponentRegistry.d.ts +48 -0
- package/dist-ui-lib/dashboard/builtInWidgets.d.ts +25 -0
- package/dist-ui-lib/dashboard/index.d.ts +13 -0
- package/dist-ui-lib/dashboard/widgets/ServiceHealthWidget.d.ts +12 -0
- package/dist-ui-lib/dashboard/widgets/index.d.ts +6 -0
- package/dist-ui-lib/index.js +5172 -0
- package/dist-ui-lib/index.js.map +1 -0
- package/dist-ui-lib/pages/AuthPage.d.ts +1 -0
- package/dist-ui-lib/pages/ConfigPage.d.ts +1 -0
- package/dist-ui-lib/pages/DashboardPage.d.ts +1 -0
- package/dist-ui-lib/pages/DiagnosticsPage.d.ts +1 -0
- package/dist-ui-lib/pages/EntitlementsPage.d.ts +17 -0
- package/dist-ui-lib/pages/LogsPage.d.ts +1 -0
- package/dist-ui-lib/pages/NotFoundPage.d.ts +1 -0
- package/dist-ui-lib/pages/PluginPage.d.ts +15 -0
- package/dist-ui-lib/pages/PluginsPage.d.ts +1 -0
- package/dist-ui-lib/pages/SystemPage.d.ts +1 -0
- package/dist-ui-lib/pages/UsersPage.d.ts +22 -0
- package/package.json +24 -7
- package/src/core/control-panel.ts +145 -61
- package/src/core/gateway.ts +863 -403
- package/src/core/index.ts +21 -2
- package/src/core/plugin-registry.ts +716 -0
- package/src/core/types.ts +31 -37
- package/src/index.ts +125 -19
- package/src/plugins/auth/adapters/auth0-adapter.ts +214 -0
- package/src/plugins/auth/adapters/basic-adapter.ts +61 -0
- package/src/plugins/auth/adapters/index.ts +10 -0
- package/src/plugins/auth/adapters/supabase-adapter.ts +149 -0
- package/src/plugins/auth/adapters/supertokens-adapter.ts +326 -0
- package/src/plugins/auth/auth-plugin.test.ts +176 -0
- package/src/plugins/auth/auth-plugin.ts +303 -0
- package/src/plugins/auth/env-config.ts +572 -0
- package/src/plugins/auth/index.ts +42 -0
- package/src/plugins/auth/supertokens-adapter.test.ts +621 -0
- package/src/plugins/auth/types.ts +245 -0
- package/src/plugins/bans/bans-plugin.ts +485 -0
- package/src/plugins/bans/index.ts +31 -0
- package/src/plugins/bans/stores/index.ts +7 -0
- package/src/plugins/bans/stores/postgres-store.ts +195 -0
- package/src/plugins/bans/types.ts +141 -0
- package/src/plugins/cache-plugin.test.ts +108 -32
- package/src/plugins/cache-plugin.ts +40 -9
- package/src/plugins/config-plugin.ts +23 -12
- package/src/plugins/diagnostics-plugin.ts +22 -12
- package/src/plugins/entitlements/entitlements-plugin.ts +820 -0
- package/src/plugins/entitlements/index.ts +51 -0
- package/src/plugins/entitlements/sources/index.ts +9 -0
- package/src/plugins/entitlements/sources/postgres-source.ts +253 -0
- package/src/plugins/entitlements/types.ts +256 -0
- package/src/plugins/frontend-app-plugin.ts +24 -12
- package/src/plugins/health-plugin.ts +27 -7
- package/src/plugins/index.ts +132 -4
- package/src/plugins/logs-plugin.ts +28 -14
- package/src/plugins/postgres-plugin.test.ts +52 -29
- package/src/plugins/postgres-plugin.ts +11 -9
- package/src/plugins/preferences/__tests__/deep-merge.test.ts +242 -0
- package/src/plugins/preferences/__tests__/preferences-plugin.test.ts +350 -0
- package/src/plugins/preferences/index.ts +30 -0
- package/src/plugins/preferences/preferences-plugin.ts +270 -0
- package/src/plugins/preferences/stores/index.ts +9 -0
- package/src/plugins/preferences/stores/postgres-store.ts +252 -0
- package/src/plugins/preferences/types.ts +100 -0
- package/src/plugins/users/__tests__/users-plugin.test.ts +690 -0
- package/src/plugins/users/index.ts +38 -0
- package/src/plugins/users/stores/index.ts +7 -0
- package/src/plugins/users/stores/postgres-store.ts +225 -0
- package/src/plugins/users/types.ts +247 -0
- package/src/plugins/users/users-plugin.ts +418 -0
- package/ui/src/App.tsx +188 -31
- package/ui/src/api/controlPanelApi.ts +453 -1
- package/ui/src/components/ControlPanelApp.tsx +212 -0
- package/ui/src/components/index.ts +62 -0
- package/ui/src/dashboard/DashboardWidgetRegistry.tsx +129 -0
- package/ui/src/dashboard/DashboardWidgetRenderer.tsx +34 -0
- package/ui/src/dashboard/PluginWidgetRenderer.tsx +118 -0
- package/ui/src/dashboard/WidgetComponentRegistry.tsx +120 -0
- package/ui/src/dashboard/builtInWidgets.tsx +35 -0
- package/ui/src/dashboard/index.ts +35 -0
- package/ui/src/dashboard/widgets/ServiceHealthWidget.tsx +140 -0
- package/ui/src/dashboard/widgets/index.ts +7 -0
- package/ui/src/pages/AuthPage.tsx +259 -0
- package/ui/src/pages/DashboardPage.tsx +28 -149
- package/ui/src/pages/EntitlementsPage.tsx +557 -0
- package/ui/src/pages/LogsPage.tsx +174 -8
- package/ui/src/pages/PluginPage.tsx +148 -0
- package/ui/src/pages/PluginsPage.tsx +394 -0
- package/ui/src/pages/SystemPage.tsx +445 -0
- package/ui/src/pages/UsersPage.tsx +837 -0
- package/ui/tsconfig.lib.json +11 -0
- package/ui/vite.lib.config.ts +56 -0
- package/dist-ui/assets/index-CW1BviRn.js +0 -465
- package/dist-ui/assets/index-CW1BviRn.js.map +0 -1
- package/ui/src/pages/HealthPage.tsx +0 -204
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Plugin Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the pluggable authentication system.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Request, Response, NextFunction, RequestHandler } from 'express';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Authenticated user information
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthenticatedUser {
|
|
15
|
+
/** Unique user ID from the provider */
|
|
16
|
+
id: string;
|
|
17
|
+
/** User's email address */
|
|
18
|
+
email: string;
|
|
19
|
+
/** User's display name */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** User's profile picture URL */
|
|
22
|
+
picture?: string;
|
|
23
|
+
/** Whether the email is verified */
|
|
24
|
+
emailVerified?: boolean;
|
|
25
|
+
/** User's roles from the provider */
|
|
26
|
+
roles?: string[];
|
|
27
|
+
/** Raw user object from the provider */
|
|
28
|
+
raw?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Auth adapter interface - all adapters must implement this
|
|
33
|
+
*/
|
|
34
|
+
export interface AuthAdapter {
|
|
35
|
+
/** Adapter name (e.g., 'auth0', 'supabase', 'basic') */
|
|
36
|
+
name: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initialize the adapter - called once during plugin setup
|
|
40
|
+
* Returns middleware to apply to the Express app
|
|
41
|
+
*/
|
|
42
|
+
initialize(): RequestHandler | RequestHandler[];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if the request is authenticated
|
|
46
|
+
*/
|
|
47
|
+
isAuthenticated(req: Request): boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get the authenticated user from the request
|
|
51
|
+
* Can be async for adapters that need to validate tokens
|
|
52
|
+
*/
|
|
53
|
+
getUser(req: Request): AuthenticatedUser | null | Promise<AuthenticatedUser | null>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Check if user has required roles (optional)
|
|
57
|
+
*/
|
|
58
|
+
hasRoles?(req: Request, roles: string[]): boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get the access token for downstream API calls (optional)
|
|
62
|
+
*/
|
|
63
|
+
getAccessToken?(req: Request): string | null;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Handler for unauthorized requests (optional custom behavior)
|
|
67
|
+
*/
|
|
68
|
+
onUnauthorized?(req: Request, res: Response): void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Cleanup resources on shutdown (optional)
|
|
72
|
+
*/
|
|
73
|
+
shutdown?(): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Auth0 adapter configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface Auth0AdapterConfig {
|
|
80
|
+
/** Auth0 domain (e.g., 'myapp.auth0.com') */
|
|
81
|
+
domain: string;
|
|
82
|
+
/** Auth0 client ID */
|
|
83
|
+
clientId: string;
|
|
84
|
+
/** Auth0 client secret */
|
|
85
|
+
clientSecret: string;
|
|
86
|
+
/** Base URL of the application */
|
|
87
|
+
baseUrl: string;
|
|
88
|
+
/** Session secret for cookie encryption */
|
|
89
|
+
secret: string;
|
|
90
|
+
/** API audience for access tokens (optional) */
|
|
91
|
+
audience?: string;
|
|
92
|
+
/** Scopes to request (default: ['openid', 'profile', 'email']) */
|
|
93
|
+
scopes?: string[];
|
|
94
|
+
/** Allowed roles - only these roles can access (optional) */
|
|
95
|
+
allowedRoles?: string[];
|
|
96
|
+
/** Allowed email domains - only these domains can access (optional) */
|
|
97
|
+
allowedDomains?: string[];
|
|
98
|
+
/** Whether to expose the access token to handlers (default: false) */
|
|
99
|
+
exposeAccessToken?: boolean;
|
|
100
|
+
/** Auth routes configuration */
|
|
101
|
+
routes?: {
|
|
102
|
+
login?: string;
|
|
103
|
+
logout?: string;
|
|
104
|
+
callback?: string;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Supabase adapter configuration
|
|
110
|
+
*/
|
|
111
|
+
export interface SupabaseAdapterConfig {
|
|
112
|
+
/** Supabase project URL */
|
|
113
|
+
url: string;
|
|
114
|
+
/** Supabase anon key */
|
|
115
|
+
anonKey: string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Basic auth adapter configuration
|
|
120
|
+
*/
|
|
121
|
+
export interface BasicAdapterConfig {
|
|
122
|
+
/** Username for basic auth */
|
|
123
|
+
username: string;
|
|
124
|
+
/** Password for basic auth */
|
|
125
|
+
password: string;
|
|
126
|
+
/** Realm name for the WWW-Authenticate header */
|
|
127
|
+
realm?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Supertokens adapter configuration
|
|
132
|
+
*/
|
|
133
|
+
export interface SupertokensAdapterConfig {
|
|
134
|
+
/** Supertokens connection URI (e.g., 'http://localhost:3567') */
|
|
135
|
+
connectionUri: string;
|
|
136
|
+
|
|
137
|
+
/** Supertokens API key (for managed service) */
|
|
138
|
+
apiKey?: string;
|
|
139
|
+
|
|
140
|
+
/** App name for branding */
|
|
141
|
+
appName: string;
|
|
142
|
+
|
|
143
|
+
/** API domain (e.g., 'http://localhost:3000') */
|
|
144
|
+
apiDomain: string;
|
|
145
|
+
|
|
146
|
+
/** Website domain (e.g., 'http://localhost:3000') */
|
|
147
|
+
websiteDomain: string;
|
|
148
|
+
|
|
149
|
+
/** API base path (default: '/auth') */
|
|
150
|
+
apiBasePath?: string;
|
|
151
|
+
|
|
152
|
+
/** Website base path (default: '/auth') */
|
|
153
|
+
websiteBasePath?: string;
|
|
154
|
+
|
|
155
|
+
/** Enable email/password auth (default: true) */
|
|
156
|
+
enableEmailPassword?: boolean;
|
|
157
|
+
|
|
158
|
+
/** Social login providers */
|
|
159
|
+
socialProviders?: {
|
|
160
|
+
google?: { clientId: string; clientSecret: string };
|
|
161
|
+
apple?: {
|
|
162
|
+
clientId: string;
|
|
163
|
+
clientSecret: string;
|
|
164
|
+
keyId: string;
|
|
165
|
+
teamId: string;
|
|
166
|
+
};
|
|
167
|
+
github?: { clientId: string; clientSecret: string };
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Auth plugin configuration
|
|
173
|
+
*/
|
|
174
|
+
export interface AuthPluginConfig {
|
|
175
|
+
/** Primary adapter for authentication */
|
|
176
|
+
adapter: AuthAdapter;
|
|
177
|
+
/** Fallback adapters checked in order if primary fails (optional) */
|
|
178
|
+
fallback?: AuthAdapter[];
|
|
179
|
+
/** Paths to exclude from authentication */
|
|
180
|
+
excludePaths?: string[];
|
|
181
|
+
/** Whether auth is required for all routes (default: true) */
|
|
182
|
+
authRequired?: boolean;
|
|
183
|
+
/** Custom unauthorized handler */
|
|
184
|
+
onUnauthorized?: (req: Request, res: Response) => void;
|
|
185
|
+
/** Enable debug logging */
|
|
186
|
+
debug?: boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Extended Express Request with auth info
|
|
191
|
+
*/
|
|
192
|
+
export interface AuthenticatedRequest extends Request {
|
|
193
|
+
auth: {
|
|
194
|
+
isAuthenticated: boolean;
|
|
195
|
+
user: AuthenticatedUser | null;
|
|
196
|
+
adapter: string;
|
|
197
|
+
accessToken?: string;
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Helper type guard for authenticated requests
|
|
203
|
+
*/
|
|
204
|
+
export function isAuthenticatedRequest(req: Request): req is AuthenticatedRequest {
|
|
205
|
+
return 'auth' in req && (req as AuthenticatedRequest).auth?.isAuthenticated === true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
209
|
+
// Environment Configuration Types
|
|
210
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Auth plugin state
|
|
214
|
+
*/
|
|
215
|
+
export type AuthPluginState = 'disabled' | 'enabled' | 'error';
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Options for createAuthPluginFromEnv (overrides only)
|
|
219
|
+
*/
|
|
220
|
+
export interface AuthEnvPluginOptions {
|
|
221
|
+
/** Paths to exclude from authentication (can also use AUTH_EXCLUDE_PATHS env var) */
|
|
222
|
+
excludePaths?: string[];
|
|
223
|
+
/** Whether auth is required (can also use AUTH_REQUIRED env var, default: true) */
|
|
224
|
+
authRequired?: boolean;
|
|
225
|
+
/** Enable debug logging (can also use AUTH_DEBUG env var) */
|
|
226
|
+
debug?: boolean;
|
|
227
|
+
/** Custom unauthorized handler */
|
|
228
|
+
onUnauthorized?: (req: Request, res: Response) => void;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Auth configuration status returned by getAuthStatus()
|
|
233
|
+
*/
|
|
234
|
+
export interface AuthConfigStatus {
|
|
235
|
+
/** Current plugin state */
|
|
236
|
+
state: AuthPluginState;
|
|
237
|
+
/** Active adapter name (null if disabled or error) */
|
|
238
|
+
adapter: string | null;
|
|
239
|
+
/** Error message if state is 'error' */
|
|
240
|
+
error?: string;
|
|
241
|
+
/** List of missing environment variables if state is 'error' */
|
|
242
|
+
missingVars?: string[];
|
|
243
|
+
/** Current configuration with secrets masked */
|
|
244
|
+
config?: Record<string, string>;
|
|
245
|
+
}
|