@rebasepro/auth 0.4.0 → 0.6.0

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,76 @@
1
+ # @rebasepro/auth
2
+
3
+ Custom JWT authentication adapter for the Rebase backend — React hooks and API utilities for email/password, OAuth, and session management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @rebasepro/auth
9
+ ```
10
+
11
+ **Peer dependencies:** `react >= 19`, `react-dom >= 19`
12
+
13
+ ## What This Package Does
14
+
15
+ `@rebasepro/auth` connects the Rebase CMS frontend to the backend's JWT authentication system. It provides a React hook (`useRebaseAuthController`) that manages login, registration, token refresh, session persistence, and user profile updates, plus a lower-level API module for direct HTTP calls to auth endpoints. For the generic `LoginView` and `RebaseAuth` UI components, see `@rebasepro/core`.
16
+
17
+ ## Key Exports
18
+
19
+ ### Hooks
20
+
21
+ | Export | Description |
22
+ |---|---|
23
+ | `useRebaseAuthController` | Main auth hook — returns a `RebaseAuthController` with login, register, logout, token refresh, session management, and profile methods. Accepts `RebaseAuthControllerProps`. |
24
+ | `useBackendUserManagement` | Hook for admin-level user CRUD (list, create, update, delete users). Returns a `UserManagement` interface. Accepts `BackendUserManagementConfig`. |
25
+
26
+ ### Types
27
+
28
+ | Export | Description |
29
+ |---|---|
30
+ | `RebaseAuthController` | Extends the base `AuthController` with email/password login, Google login, generic OAuth, registration, password reset/change, session management, and profile updates. |
31
+ | `RebaseAuthControllerProps` | Config for `useRebaseAuthController` — `client`, `apiUrl`, `googleClientId`, `onSignOut`, `defineRolesFor`. |
32
+ | `AuthTokens` | `{ accessToken, refreshToken, accessTokenExpiresAt }` |
33
+ | `UserInfo` | `{ uid, email, displayName, photoURL, emailVerified, roles, metadata }` |
34
+ | `AuthResponse` | `{ user: UserInfo, tokens: AuthTokens }` |
35
+ | `RefreshResponse` | `{ tokens: AuthTokens }` |
36
+ | `BackendUserManagementConfig` | Config for `useBackendUserManagement`. |
37
+ | `UserManagement` | Interface returned by `useBackendUserManagement`. |
38
+
39
+ ### API Utilities
40
+
41
+ | Export | Description |
42
+ |---|---|
43
+ | `setApiUrl(url)` | Set the base API URL for all auth requests |
44
+ | `getApiUrl()` | Get the current base API URL |
45
+ | `fetchAuthConfig()` | Fetch auth config from `/api/auth/config` (cached, deduplicated) |
46
+ | `AuthApiError` | Error class with `message` and `code` fields |
47
+ | `AuthConfigResponse` | Type — `{ needsSetup, registrationEnabled, emailServiceEnabled, passwordReset, emailVerification, enabledProviders }` |
48
+
49
+ ## Quick Start
50
+
51
+ ```tsx
52
+ import { useRebaseAuthController } from "@rebasepro/auth";
53
+ import { createRebaseClient } from "@rebasepro/client";
54
+
55
+ const client = createRebaseClient({ baseUrl: "http://localhost:3001" });
56
+
57
+ function App() {
58
+ const authController = useRebaseAuthController({
59
+ client,
60
+ apiUrl: "http://localhost:3001",
61
+ });
62
+
63
+ // authController.emailPasswordLogin(email, password)
64
+ // authController.googleLogin({ idToken })
65
+ // authController.register(email, password, displayName)
66
+ // authController.signOut()
67
+ // authController.user — current logged-in user or null
68
+ }
69
+ ```
70
+
71
+ ## Related Packages
72
+
73
+ - [`@rebasepro/core`](../core) — `LoginView`, `RebaseAuth` UI components, `AuthController` base type
74
+ - [`@rebasepro/client`](../client) — HTTP client with its own `auth` module for direct API calls
75
+ - [`@rebasepro/types`](../types) — Base `AuthController` and `User` types
76
+ - [`@rebasepro/ui`](../ui) — UI components used by auth views
package/dist/index.d.ts CHANGED
@@ -8,7 +8,5 @@
8
8
  */
9
9
  export type { RebaseAuthController, RebaseAuthControllerProps, AuthTokens, UserInfo, AuthResponse, RefreshResponse } from "./types";
10
10
  export { useRebaseAuthController } from "./hooks/useRebaseAuthController";
11
- export { useBackendUserManagement } from "./hooks/useBackendUserManagement";
12
- export type { BackendUserManagementConfig, UserManagement } from "./hooks/useBackendUserManagement";
13
11
  export { setApiUrl, getApiUrl, fetchAuthConfig, AuthApiError } from "./api";
14
12
  export type { AuthConfigResponse } from "./api";