@rebasepro/auth 0.4.0 → 0.5.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 +76 -0
- package/package.json +4 -4
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/auth",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"source": "src/index.ts",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@rebasepro/
|
|
15
|
-
"@rebasepro/
|
|
16
|
-
"@rebasepro/
|
|
14
|
+
"@rebasepro/ui": "0.5.0",
|
|
15
|
+
"@rebasepro/core": "0.5.0",
|
|
16
|
+
"@rebasepro/types": "0.5.0"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">=19.0.0",
|