@invect/user-auth 0.0.1 → 0.0.3

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.
Files changed (38) hide show
  1. package/README.md +81 -72
  2. package/dist/backend/index.cjs +410 -54
  3. package/dist/backend/index.cjs.map +1 -1
  4. package/dist/backend/index.d.cts +456 -0
  5. package/dist/backend/index.d.cts.map +1 -0
  6. package/dist/backend/index.d.mts +456 -0
  7. package/dist/backend/index.d.mts.map +1 -0
  8. package/dist/backend/index.d.ts +28 -18
  9. package/dist/backend/index.d.ts.map +1 -1
  10. package/dist/backend/index.mjs +408 -53
  11. package/dist/backend/index.mjs.map +1 -1
  12. package/dist/backend/plugin.d.ts +15 -15
  13. package/dist/backend/plugin.d.ts.map +1 -1
  14. package/dist/backend/types.d.ts +85 -9
  15. package/dist/backend/types.d.ts.map +1 -1
  16. package/dist/frontend/components/ApiKeysDialog.d.ts +17 -0
  17. package/dist/frontend/components/ApiKeysDialog.d.ts.map +1 -0
  18. package/dist/frontend/components/AuthenticatedInvect.d.ts +10 -10
  19. package/dist/frontend/components/SignInForm.d.ts.map +1 -1
  20. package/dist/frontend/components/SignInPage.d.ts.map +1 -1
  21. package/dist/frontend/components/UserManagement.d.ts.map +1 -1
  22. package/dist/frontend/index.cjs +434 -58
  23. package/dist/frontend/index.cjs.map +1 -1
  24. package/dist/frontend/index.d.cts +317 -0
  25. package/dist/frontend/index.d.cts.map +1 -0
  26. package/dist/frontend/index.d.mts +317 -0
  27. package/dist/frontend/index.d.mts.map +1 -0
  28. package/dist/frontend/index.d.ts +3 -1
  29. package/dist/frontend/index.d.ts.map +1 -1
  30. package/dist/frontend/index.mjs +418 -43
  31. package/dist/frontend/index.mjs.map +1 -1
  32. package/dist/frontend/plugins/authFrontendPlugin.d.ts +2 -2
  33. package/dist/frontend/plugins/authFrontendPlugin.d.ts.map +1 -1
  34. package/dist/shared/types.d.cts +49 -0
  35. package/dist/shared/types.d.cts.map +1 -0
  36. package/dist/shared/types.d.mts +49 -0
  37. package/dist/shared/types.d.mts.map +1 -0
  38. package/package.json +68 -66
@@ -0,0 +1,317 @@
1
+ import { AuthError, AuthSession, AuthUser, CreateUserInput, SignInCredentials, SignUpCredentials, UpdateUserRoleInput } from "../shared/types.cjs";
2
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import { ComponentType, MemoExoticComponent, ReactNode } from "react";
4
+ import { QueryClient } from "@tanstack/react-query";
5
+ import { InvectFrontendPlugin } from "@invect/ui";
6
+
7
+ //#region src/frontend/providers/AuthProvider.d.ts
8
+ interface AuthContextValue {
9
+ /** Current authenticated user, null if not signed in */
10
+ user: AuthUser | null;
11
+ /** Whether the user is authenticated */
12
+ isAuthenticated: boolean;
13
+ /** Whether the session query is still loading */
14
+ isLoading: boolean;
15
+ /** Sign in with email/password */
16
+ signIn: (credentials: SignInCredentials) => Promise<void>;
17
+ /** Sign up with email/password */
18
+ signUp: (credentials: SignUpCredentials) => Promise<void>;
19
+ /** Sign out the current session */
20
+ signOut: () => Promise<void>;
21
+ /** Whether a sign-in is in progress */
22
+ isSigningIn: boolean;
23
+ /** Whether a sign-up is in progress */
24
+ isSigningUp: boolean;
25
+ /** Last auth error, if any */
26
+ error: string | null;
27
+ }
28
+ interface AuthProviderProps {
29
+ children: ReactNode;
30
+ /**
31
+ * Base URL for the Invect API (e.g. 'http://localhost:3000/invect').
32
+ * Auth endpoints are at `${baseUrl}/plugins/auth/api/auth/*`.
33
+ */
34
+ baseUrl: string;
35
+ }
36
+ declare function AuthProvider({
37
+ children,
38
+ baseUrl
39
+ }: AuthProviderProps): react_jsx_runtime0.JSX.Element;
40
+ /**
41
+ * Access auth context — current user, sign-in/sign-up/sign-out actions.
42
+ *
43
+ * Must be used within an `<AuthProvider>`.
44
+ * Returns a safe fallback (unauthenticated) if provider is missing.
45
+ */
46
+ declare function useAuth(): AuthContextValue;
47
+ //#endregion
48
+ //#region src/frontend/components/SignInForm.d.ts
49
+ /**
50
+ * SignInForm — Email/password sign-in form component.
51
+ *
52
+ * Uses the AuthProvider's signIn action. Styled to match the Invect
53
+ * design system with grouped fields, clean labels, and themed inputs.
54
+ */
55
+ interface SignInFormProps {
56
+ /** Called after successful sign-in */
57
+ onSuccess?: () => void;
58
+ /** Additional CSS class names */
59
+ className?: string;
60
+ }
61
+ declare function SignInForm({
62
+ onSuccess,
63
+ className
64
+ }: SignInFormProps): react_jsx_runtime0.JSX.Element;
65
+ //#endregion
66
+ //#region src/frontend/components/SignInPage.d.ts
67
+ /**
68
+ * SignInPage — Full-page sign-in component with layout.
69
+ *
70
+ * Renders the SignInForm centered on the page with a logo, title,
71
+ * and grouped fields matching the Invect design system.
72
+ * Sign-up is not offered — new users are created by admins.
73
+ */
74
+ interface SignInPageProps {
75
+ /** Called after successful sign-in */
76
+ onSuccess?: () => void;
77
+ /** Called when user clicks "Sign Up" link (optional — hidden if omitted) */
78
+ onNavigateToSignUp?: () => void;
79
+ /** Page title */
80
+ title?: string;
81
+ /** Page subtitle */
82
+ subtitle?: string;
83
+ }
84
+ declare function SignInPage({
85
+ onSuccess,
86
+ onNavigateToSignUp,
87
+ title,
88
+ subtitle
89
+ }: SignInPageProps): react_jsx_runtime0.JSX.Element;
90
+ //#endregion
91
+ //#region src/frontend/components/UserButton.d.ts
92
+ /**
93
+ * UserButton — Compact user avatar + dropdown for the authenticated user.
94
+ *
95
+ * Shows the user's avatar/initials when signed in, with a dropdown
96
+ * containing their name, email, and sign-out button.
97
+ * Shows a "Sign In" button when not authenticated.
98
+ */
99
+ interface UserButtonProps {
100
+ /** Called when the sign-in button is clicked (unauthenticated state) */
101
+ onSignInClick?: () => void;
102
+ /** Additional CSS class names */
103
+ className?: string;
104
+ }
105
+ declare function UserButton({
106
+ onSignInClick,
107
+ className
108
+ }: UserButtonProps): react_jsx_runtime0.JSX.Element;
109
+ //#endregion
110
+ //#region src/frontend/components/AuthGate.d.ts
111
+ interface AuthGateProps {
112
+ /** Content to show when authenticated */
113
+ children: ReactNode;
114
+ /** Content to show when NOT authenticated (defaults to null) */
115
+ fallback?: ReactNode;
116
+ /** Content to show while loading (defaults to null) */
117
+ loading?: ReactNode;
118
+ }
119
+ declare function AuthGate({
120
+ children,
121
+ fallback,
122
+ loading
123
+ }: AuthGateProps): react_jsx_runtime0.JSX.Element;
124
+ //#endregion
125
+ //#region src/frontend/components/UserManagement.d.ts
126
+ /**
127
+ * UserManagement — Admin panel for managing users.
128
+ *
129
+ * Displays a list of users with the ability to:
130
+ * - Create new users (email/password/role)
131
+ * - Change user roles
132
+ * - Delete users
133
+ *
134
+ * Only visible to admin users. Uses the auth plugin's
135
+ * `/plugins/auth/users` endpoints.
136
+ */
137
+ interface UserManagementProps {
138
+ /** Base URL for the Invect API (same as AuthProvider's baseUrl) */
139
+ apiBaseUrl: string;
140
+ /** Additional CSS class names */
141
+ className?: string;
142
+ }
143
+ declare function UserManagement({
144
+ apiBaseUrl,
145
+ className
146
+ }: UserManagementProps): react_jsx_runtime0.JSX.Element | null;
147
+ //#endregion
148
+ //#region src/frontend/components/ApiKeysDialog.d.ts
149
+ /**
150
+ * ApiKeysDialog — Admin dialog for managing API keys.
151
+ *
152
+ * Displays a list of API keys with the ability to:
153
+ * - Create new API keys (name, optional expiry)
154
+ * - Copy newly created keys
155
+ * - Delete existing keys
156
+ *
157
+ * Only functional when the auth plugin has API keys enabled.
158
+ */
159
+ interface ApiKeysDialogProps {
160
+ open: boolean;
161
+ onOpenChange: (open: boolean) => void;
162
+ apiBaseUrl: string;
163
+ }
164
+ declare function ApiKeysDialog({
165
+ open,
166
+ onOpenChange,
167
+ apiBaseUrl
168
+ }: ApiKeysDialogProps): react_jsx_runtime0.JSX.Element;
169
+ //#endregion
170
+ //#region src/frontend/components/AuthenticatedInvect.d.ts
171
+ /**
172
+ * Accepts both a plain component and a React.memo-wrapped component.
173
+ * React.memo returns MemoExoticComponent which isn't directly assignable
174
+ * to ComponentType in TypeScript, but is valid in JSX.
175
+ */
176
+ type ComponentOrMemo<P> = ComponentType<P> | MemoExoticComponent<ComponentType<P>>;
177
+ /**
178
+ * Generic over TPlugin so that passing a typed InvectComponent (e.g. one that
179
+ * expects `plugins?: InvectFrontendPlugin[]`) causes TypeScript to infer the
180
+ * correct element type for the `plugins` prop on AuthenticatedInvect itself.
181
+ * Defaults to `unknown` for the no-plugins case.
182
+ */
183
+ interface AuthenticatedInvectProps<TPlugin = unknown> {
184
+ /**
185
+ * Base URL for the Invect API.
186
+ * Used for both auth endpoints and the Invect component.
187
+ * @example '/api/invect' or 'http://localhost:3000/invect'
188
+ */
189
+ apiBaseUrl?: string;
190
+ /**
191
+ * Base path where Invect is mounted in the browser.
192
+ * @default '/invect'
193
+ */
194
+ basePath?: string;
195
+ /**
196
+ * The Invect component to render when authenticated.
197
+ * Pass this to avoid a direct dependency on @invect/ui.
198
+ * Accepts both plain and React.memo-wrapped components.
199
+ *
200
+ * @example
201
+ * ```tsx
202
+ * import { Invect } from '@invect/ui';
203
+ * <AuthenticatedInvect InvectComponent={Invect} />
204
+ * ```
205
+ */
206
+ InvectComponent: ComponentOrMemo<{
207
+ apiBaseUrl?: string;
208
+ basePath?: string;
209
+ reactQueryClient?: QueryClient;
210
+ plugins?: TPlugin[];
211
+ }>;
212
+ /**
213
+ * The InvectShell component that provides the `.invect` CSS scope.
214
+ * This ensures theme tokens work for both the sign-in page and the
215
+ * Invect editor. Import from `@invect/ui`.
216
+ *
217
+ * `children` is typed as `unknown` rather than `ReactNode` to avoid a
218
+ * structural incompatibility between `@types/react@18` (used here) and
219
+ * `@types/react@19` (used by `@invect/ui`) where `ReactPortal`
220
+ * changed between versions.
221
+ *
222
+ * If not provided, the auth UI renders without the Invect CSS scope
223
+ * and must rely on the host app's styling.
224
+ *
225
+ * @example
226
+ * ```tsx
227
+ * import { InvectShell } from '@invect/ui';
228
+ * <AuthenticatedInvect ShellComponent={InvectShell} />
229
+ * ```
230
+ */
231
+ ShellComponent?: ComponentOrMemo<{
232
+ children: ReactNode;
233
+ theme?: 'light' | 'dark' | 'system';
234
+ className?: string;
235
+ }>;
236
+ /**
237
+ * Optional React Query client. If provided, it's shared between
238
+ * the auth provider and the Invect component.
239
+ */
240
+ reactQueryClient?: QueryClient;
241
+ /**
242
+ * Content to display while checking session status.
243
+ */
244
+ loading?: ReactNode;
245
+ /**
246
+ * Theme for the shell wrapper.
247
+ * @default 'system'
248
+ */
249
+ theme?: 'light' | 'dark' | 'system';
250
+ /**
251
+ * Frontend plugins forwarded to InvectComponent.
252
+ * The element type is inferred from InvectComponent's `plugins` prop type,
253
+ * so this stays consistent with whatever component you pass.
254
+ *
255
+ * @example
256
+ * ```tsx
257
+ * import { rbacFrontend } from '@invect/rbac/ui';
258
+ * <AuthenticatedInvect plugins={[rbacFrontend]} />
259
+ * ```
260
+ */
261
+ plugins?: TPlugin[];
262
+ }
263
+ declare function AuthenticatedInvect<TPlugin = unknown>({
264
+ apiBaseUrl,
265
+ basePath,
266
+ InvectComponent,
267
+ ShellComponent,
268
+ reactQueryClient,
269
+ loading,
270
+ theme,
271
+ plugins
272
+ }: AuthenticatedInvectProps<TPlugin>): react_jsx_runtime0.JSX.Element;
273
+ //#endregion
274
+ //#region src/frontend/components/UserManagementPage.d.ts
275
+ /**
276
+ * UserManagementPage — Standalone page for user management.
277
+ *
278
+ * Wraps the existing UserManagement component in a page layout
279
+ * consistent with the Access Control page style. Registered as a
280
+ * plugin route contribution at '/users'.
281
+ */
282
+ declare function UserManagementPage(): react_jsx_runtime0.JSX.Element;
283
+ //#endregion
284
+ //#region src/frontend/components/ProfilePage.d.ts
285
+ /**
286
+ * ProfilePage — Standalone page for the current authenticated user.
287
+ *
288
+ * Shows basic account information and provides a sign-out action.
289
+ */
290
+ interface ProfilePageProps {
291
+ basePath: string;
292
+ }
293
+ declare function ProfilePage({
294
+ basePath
295
+ }: ProfilePageProps): react_jsx_runtime0.JSX.Element;
296
+ //#endregion
297
+ //#region src/frontend/components/SidebarUserMenu.d.ts
298
+ /**
299
+ * SidebarUserMenu — User avatar link in the sidebar footer.
300
+ *
301
+ * Clicking navigates directly to the profile page.
302
+ * Sign-out is available on the profile page itself.
303
+ */
304
+ interface SidebarUserMenuProps {
305
+ collapsed?: boolean;
306
+ basePath?: string;
307
+ }
308
+ declare function SidebarUserMenu({
309
+ collapsed,
310
+ basePath
311
+ }: SidebarUserMenuProps): react_jsx_runtime0.JSX.Element | null;
312
+ //#endregion
313
+ //#region src/frontend/plugins/authFrontendPlugin.d.ts
314
+ declare const authFrontend: InvectFrontendPlugin;
315
+ //#endregion
316
+ export { ApiKeysDialog, type ApiKeysDialogProps, type AuthContextValue, type AuthError, AuthGate, type AuthGateProps, AuthProvider, type AuthProviderProps, type AuthSession, type AuthUser, AuthenticatedInvect, type AuthenticatedInvectProps, type CreateUserInput, ProfilePage, SidebarUserMenu, type SidebarUserMenuProps, type SignInCredentials, SignInForm, type SignInFormProps, SignInPage, type SignInPageProps, type UpdateUserRoleInput, UserButton, type UserButtonProps, UserManagement, UserManagementPage, type UserManagementProps, authFrontend, useAuth };
317
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/frontend/providers/AuthProvider.tsx","../../src/frontend/components/SignInForm.tsx","../../src/frontend/components/SignInPage.tsx","../../src/frontend/components/UserButton.tsx","../../src/frontend/components/AuthGate.tsx","../../src/frontend/components/UserManagement.tsx","../../src/frontend/components/ApiKeysDialog.tsx","../../src/frontend/components/AuthenticatedInvect.tsx","../../src/frontend/components/UserManagementPage.tsx","../../src/frontend/components/ProfilePage.tsx","../../src/frontend/components/SidebarUserMenu.tsx","../../src/frontend/plugins/authFrontendPlugin.ts"],"mappings":";;;;;;;UAqBiB,gBAAA;EAET;EAAN,IAAA,EAAM,QAAA;EAMsC;EAJ5C,eAAA;EAM4C;EAJ5C,SAAA;EAMsB;EAJtB,MAAA,GAAS,WAAA,EAAa,iBAAA,KAAsB,OAAA;EAN5C;EAQA,MAAA,GAAS,WAAA,EAAa,i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SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,eAAA,CAAA;EAAkB,SAAA;EAAmB;AAAA,GAAiB,oBAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;cCG7E,YAAA,EAAc,oBAAA"}
@@ -0,0 +1,317 @@
1
+ import { AuthError, AuthSession, AuthUser, CreateUserInput, SignInCredentials, SignUpCredentials, UpdateUserRoleInput } from "../shared/types.mjs";
2
+ import { ComponentType, MemoExoticComponent, ReactNode } from "react";
3
+ import { QueryClient } from "@tanstack/react-query";
4
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+ import { InvectFrontendPlugin } from "@invect/ui";
6
+
7
+ //#region src/frontend/providers/AuthProvider.d.ts
8
+ interface AuthContextValue {
9
+ /** Current authenticated user, null if not signed in */
10
+ user: AuthUser | null;
11
+ /** Whether the user is authenticated */
12
+ isAuthenticated: boolean;
13
+ /** Whether the session query is still loading */
14
+ isLoading: boolean;
15
+ /** Sign in with email/password */
16
+ signIn: (credentials: SignInCredentials) => Promise<void>;
17
+ /** Sign up with email/password */
18
+ signUp: (credentials: SignUpCredentials) => Promise<void>;
19
+ /** Sign out the current session */
20
+ signOut: () => Promise<void>;
21
+ /** Whether a sign-in is in progress */
22
+ isSigningIn: boolean;
23
+ /** Whether a sign-up is in progress */
24
+ isSigningUp: boolean;
25
+ /** Last auth error, if any */
26
+ error: string | null;
27
+ }
28
+ interface AuthProviderProps {
29
+ children: ReactNode;
30
+ /**
31
+ * Base URL for the Invect API (e.g. 'http://localhost:3000/invect').
32
+ * Auth endpoints are at `${baseUrl}/plugins/auth/api/auth/*`.
33
+ */
34
+ baseUrl: string;
35
+ }
36
+ declare function AuthProvider({
37
+ children,
38
+ baseUrl
39
+ }: AuthProviderProps): react_jsx_runtime0.JSX.Element;
40
+ /**
41
+ * Access auth context — current user, sign-in/sign-up/sign-out actions.
42
+ *
43
+ * Must be used within an `<AuthProvider>`.
44
+ * Returns a safe fallback (unauthenticated) if provider is missing.
45
+ */
46
+ declare function useAuth(): AuthContextValue;
47
+ //#endregion
48
+ //#region src/frontend/components/SignInForm.d.ts
49
+ /**
50
+ * SignInForm — Email/password sign-in form component.
51
+ *
52
+ * Uses the AuthProvider's signIn action. Styled to match the Invect
53
+ * design system with grouped fields, clean labels, and themed inputs.
54
+ */
55
+ interface SignInFormProps {
56
+ /** Called after successful sign-in */
57
+ onSuccess?: () => void;
58
+ /** Additional CSS class names */
59
+ className?: string;
60
+ }
61
+ declare function SignInForm({
62
+ onSuccess,
63
+ className
64
+ }: SignInFormProps): react_jsx_runtime0.JSX.Element;
65
+ //#endregion
66
+ //#region src/frontend/components/SignInPage.d.ts
67
+ /**
68
+ * SignInPage — Full-page sign-in component with layout.
69
+ *
70
+ * Renders the SignInForm centered on the page with a logo, title,
71
+ * and grouped fields matching the Invect design system.
72
+ * Sign-up is not offered — new users are created by admins.
73
+ */
74
+ interface SignInPageProps {
75
+ /** Called after successful sign-in */
76
+ onSuccess?: () => void;
77
+ /** Called when user clicks "Sign Up" link (optional — hidden if omitted) */
78
+ onNavigateToSignUp?: () => void;
79
+ /** Page title */
80
+ title?: string;
81
+ /** Page subtitle */
82
+ subtitle?: string;
83
+ }
84
+ declare function SignInPage({
85
+ onSuccess,
86
+ onNavigateToSignUp,
87
+ title,
88
+ subtitle
89
+ }: SignInPageProps): react_jsx_runtime0.JSX.Element;
90
+ //#endregion
91
+ //#region src/frontend/components/UserButton.d.ts
92
+ /**
93
+ * UserButton — Compact user avatar + dropdown for the authenticated user.
94
+ *
95
+ * Shows the user's avatar/initials when signed in, with a dropdown
96
+ * containing their name, email, and sign-out button.
97
+ * Shows a "Sign In" button when not authenticated.
98
+ */
99
+ interface UserButtonProps {
100
+ /** Called when the sign-in button is clicked (unauthenticated state) */
101
+ onSignInClick?: () => void;
102
+ /** Additional CSS class names */
103
+ className?: string;
104
+ }
105
+ declare function UserButton({
106
+ onSignInClick,
107
+ className
108
+ }: UserButtonProps): react_jsx_runtime0.JSX.Element;
109
+ //#endregion
110
+ //#region src/frontend/components/AuthGate.d.ts
111
+ interface AuthGateProps {
112
+ /** Content to show when authenticated */
113
+ children: ReactNode;
114
+ /** Content to show when NOT authenticated (defaults to null) */
115
+ fallback?: ReactNode;
116
+ /** Content to show while loading (defaults to null) */
117
+ loading?: ReactNode;
118
+ }
119
+ declare function AuthGate({
120
+ children,
121
+ fallback,
122
+ loading
123
+ }: AuthGateProps): react_jsx_runtime0.JSX.Element;
124
+ //#endregion
125
+ //#region src/frontend/components/UserManagement.d.ts
126
+ /**
127
+ * UserManagement — Admin panel for managing users.
128
+ *
129
+ * Displays a list of users with the ability to:
130
+ * - Create new users (email/password/role)
131
+ * - Change user roles
132
+ * - Delete users
133
+ *
134
+ * Only visible to admin users. Uses the auth plugin's
135
+ * `/plugins/auth/users` endpoints.
136
+ */
137
+ interface UserManagementProps {
138
+ /** Base URL for the Invect API (same as AuthProvider's baseUrl) */
139
+ apiBaseUrl: string;
140
+ /** Additional CSS class names */
141
+ className?: string;
142
+ }
143
+ declare function UserManagement({
144
+ apiBaseUrl,
145
+ className
146
+ }: UserManagementProps): react_jsx_runtime0.JSX.Element | null;
147
+ //#endregion
148
+ //#region src/frontend/components/ApiKeysDialog.d.ts
149
+ /**
150
+ * ApiKeysDialog — Admin dialog for managing API keys.
151
+ *
152
+ * Displays a list of API keys with the ability to:
153
+ * - Create new API keys (name, optional expiry)
154
+ * - Copy newly created keys
155
+ * - Delete existing keys
156
+ *
157
+ * Only functional when the auth plugin has API keys enabled.
158
+ */
159
+ interface ApiKeysDialogProps {
160
+ open: boolean;
161
+ onOpenChange: (open: boolean) => void;
162
+ apiBaseUrl: string;
163
+ }
164
+ declare function ApiKeysDialog({
165
+ open,
166
+ onOpenChange,
167
+ apiBaseUrl
168
+ }: ApiKeysDialogProps): react_jsx_runtime0.JSX.Element;
169
+ //#endregion
170
+ //#region src/frontend/components/AuthenticatedInvect.d.ts
171
+ /**
172
+ * Accepts both a plain component and a React.memo-wrapped component.
173
+ * React.memo returns MemoExoticComponent which isn't directly assignable
174
+ * to ComponentType in TypeScript, but is valid in JSX.
175
+ */
176
+ type ComponentOrMemo<P> = ComponentType<P> | MemoExoticComponent<ComponentType<P>>;
177
+ /**
178
+ * Generic over TPlugin so that passing a typed InvectComponent (e.g. one that
179
+ * expects `plugins?: InvectFrontendPlugin[]`) causes TypeScript to infer the
180
+ * correct element type for the `plugins` prop on AuthenticatedInvect itself.
181
+ * Defaults to `unknown` for the no-plugins case.
182
+ */
183
+ interface AuthenticatedInvectProps<TPlugin = unknown> {
184
+ /**
185
+ * Base URL for the Invect API.
186
+ * Used for both auth endpoints and the Invect component.
187
+ * @example '/api/invect' or 'http://localhost:3000/invect'
188
+ */
189
+ apiBaseUrl?: string;
190
+ /**
191
+ * Base path where Invect is mounted in the browser.
192
+ * @default '/invect'
193
+ */
194
+ basePath?: string;
195
+ /**
196
+ * The Invect component to render when authenticated.
197
+ * Pass this to avoid a direct dependency on @invect/ui.
198
+ * Accepts both plain and React.memo-wrapped components.
199
+ *
200
+ * @example
201
+ * ```tsx
202
+ * import { Invect } from '@invect/ui';
203
+ * <AuthenticatedInvect InvectComponent={Invect} />
204
+ * ```
205
+ */
206
+ InvectComponent: ComponentOrMemo<{
207
+ apiBaseUrl?: string;
208
+ basePath?: string;
209
+ reactQueryClient?: QueryClient;
210
+ plugins?: TPlugin[];
211
+ }>;
212
+ /**
213
+ * The InvectShell component that provides the `.invect` CSS scope.
214
+ * This ensures theme tokens work for both the sign-in page and the
215
+ * Invect editor. Import from `@invect/ui`.
216
+ *
217
+ * `children` is typed as `unknown` rather than `ReactNode` to avoid a
218
+ * structural incompatibility between `@types/react@18` (used here) and
219
+ * `@types/react@19` (used by `@invect/ui`) where `ReactPortal`
220
+ * changed between versions.
221
+ *
222
+ * If not provided, the auth UI renders without the Invect CSS scope
223
+ * and must rely on the host app's styling.
224
+ *
225
+ * @example
226
+ * ```tsx
227
+ * import { InvectShell } from '@invect/ui';
228
+ * <AuthenticatedInvect ShellComponent={InvectShell} />
229
+ * ```
230
+ */
231
+ ShellComponent?: ComponentOrMemo<{
232
+ children: ReactNode;
233
+ theme?: 'light' | 'dark' | 'system';
234
+ className?: string;
235
+ }>;
236
+ /**
237
+ * Optional React Query client. If provided, it's shared between
238
+ * the auth provider and the Invect component.
239
+ */
240
+ reactQueryClient?: QueryClient;
241
+ /**
242
+ * Content to display while checking session status.
243
+ */
244
+ loading?: ReactNode;
245
+ /**
246
+ * Theme for the shell wrapper.
247
+ * @default 'system'
248
+ */
249
+ theme?: 'light' | 'dark' | 'system';
250
+ /**
251
+ * Frontend plugins forwarded to InvectComponent.
252
+ * The element type is inferred from InvectComponent's `plugins` prop type,
253
+ * so this stays consistent with whatever component you pass.
254
+ *
255
+ * @example
256
+ * ```tsx
257
+ * import { rbacFrontend } from '@invect/rbac/ui';
258
+ * <AuthenticatedInvect plugins={[rbacFrontend]} />
259
+ * ```
260
+ */
261
+ plugins?: TPlugin[];
262
+ }
263
+ declare function AuthenticatedInvect<TPlugin = unknown>({
264
+ apiBaseUrl,
265
+ basePath,
266
+ InvectComponent,
267
+ ShellComponent,
268
+ reactQueryClient,
269
+ loading,
270
+ theme,
271
+ plugins
272
+ }: AuthenticatedInvectProps<TPlugin>): react_jsx_runtime0.JSX.Element;
273
+ //#endregion
274
+ //#region src/frontend/components/UserManagementPage.d.ts
275
+ /**
276
+ * UserManagementPage — Standalone page for user management.
277
+ *
278
+ * Wraps the existing UserManagement component in a page layout
279
+ * consistent with the Access Control page style. Registered as a
280
+ * plugin route contribution at '/users'.
281
+ */
282
+ declare function UserManagementPage(): react_jsx_runtime0.JSX.Element;
283
+ //#endregion
284
+ //#region src/frontend/components/ProfilePage.d.ts
285
+ /**
286
+ * ProfilePage — Standalone page for the current authenticated user.
287
+ *
288
+ * Shows basic account information and provides a sign-out action.
289
+ */
290
+ interface ProfilePageProps {
291
+ basePath: string;
292
+ }
293
+ declare function ProfilePage({
294
+ basePath
295
+ }: ProfilePageProps): react_jsx_runtime0.JSX.Element;
296
+ //#endregion
297
+ //#region src/frontend/components/SidebarUserMenu.d.ts
298
+ /**
299
+ * SidebarUserMenu — User avatar link in the sidebar footer.
300
+ *
301
+ * Clicking navigates directly to the profile page.
302
+ * Sign-out is available on the profile page itself.
303
+ */
304
+ interface SidebarUserMenuProps {
305
+ collapsed?: boolean;
306
+ basePath?: string;
307
+ }
308
+ declare function SidebarUserMenu({
309
+ collapsed,
310
+ basePath
311
+ }: SidebarUserMenuProps): react_jsx_runtime0.JSX.Element | null;
312
+ //#endregion
313
+ //#region src/frontend/plugins/authFrontendPlugin.d.ts
314
+ declare const authFrontend: InvectFrontendPlugin;
315
+ //#endregion
316
+ export { ApiKeysDialog, type ApiKeysDialogProps, type AuthContextValue, type AuthError, AuthGate, type AuthGateProps, AuthProvider, type AuthProviderProps, type AuthSession, type AuthUser, AuthenticatedInvect, type AuthenticatedInvectProps, type CreateUserInput, ProfilePage, SidebarUserMenu, type SidebarUserMenuProps, type SignInCredentials, SignInForm, type SignInFormProps, SignInPage, type SignInPageProps, type UpdateUserRoleInput, UserButton, type UserButtonProps, UserManagement, UserManagementPage, type UserManagementProps, authFrontend, useAuth };
317
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/frontend/providers/AuthProvider.tsx","../../src/frontend/components/SignInForm.tsx","../../src/frontend/components/SignInPage.tsx","../../src/frontend/components/UserButton.tsx","../../src/frontend/components/AuthGate.tsx","../../src/frontend/components/UserManagement.tsx","../../src/frontend/components/ApiKeysDialog.tsx","../../src/frontend/components/AuthenticatedInvect.tsx","../../src/frontend/components/UserManagementPage.tsx","../../src/frontend/components/ProfilePage.tsx","../../src/frontend/components/SidebarUserMenu.tsx","../../src/frontend/plugins/authFrontendPlugin.ts"],"mappings":";;;;;;;UAqBiB,gBAAA;EAET;EAAN,IAAA,EAAM,QAAA;EAMsC;EAJ5C,eAAA;EAM4C;EAJ5C,SAAA;EAMsB;EAJ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AAAA,GAAY,gBAAA,GAAgB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;;;;;;;UCLzC,oBAAA;EACf,SAAA;EACA,QAAA;AAAA;AAAA,iBAGc,eAAA,CAAA;EAAkB,SAAA;EAAmB;AAAA,GAAiB,oBAAA,GAAoB,kBAAA,CAAA,GAAA,CAAA,OAAA;;;cCG7E,YAAA,EAAc,oBAAA"}
@@ -18,12 +18,14 @@ export { AuthGate } from './components/AuthGate';
18
18
  export type { AuthGateProps } from './components/AuthGate';
19
19
  export { UserManagement } from './components/UserManagement';
20
20
  export type { UserManagementProps } from './components/UserManagement';
21
+ export { ApiKeysDialog } from './components/ApiKeysDialog';
22
+ export type { ApiKeysDialogProps } from './components/ApiKeysDialog';
21
23
  export { AuthenticatedInvect } from './components/AuthenticatedInvect';
22
24
  export type { AuthenticatedInvectProps } from './components/AuthenticatedInvect';
23
25
  export { UserManagementPage } from './components/UserManagementPage';
24
26
  export { ProfilePage } from './components/ProfilePage';
25
27
  export { SidebarUserMenu } from './components/SidebarUserMenu';
26
28
  export type { SidebarUserMenuProps } from './components/SidebarUserMenu';
27
- export { authFrontendPlugin } from './plugins/authFrontendPlugin';
29
+ export { authFrontend } from './plugins/authFrontendPlugin';
28
30
  export type { AuthSession, AuthUser, SignInCredentials, CreateUserInput, UpdateUserRoleInput, AuthError, } from '../shared/types';
29
31
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/frontend/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,UAAU,E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